Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2ca0c6c

Browse files
committed
gh-84808: Handle errors returned by internal_connect()
Python shouldn't assume that errno codes are positive. reported and proposed by Ryan C. Gordon
1 parent d9efa45 commit 2ca0c6c

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

Modules/socketmodule.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3489,7 +3489,7 @@ sock_connect(PySocketSockObject *s, PyObject *addro)
34893489
}
34903490

34913491
res = internal_connect(s, SAS2SA(&addrbuf), addrlen, 1);
3492-
if (res < 0)
3492+
if (res == -1)
34933493
return NULL;
34943494

34953495
Py_RETURN_NONE;
@@ -3520,7 +3520,7 @@ sock_connect_ex(PySocketSockObject *s, PyObject *addro)
35203520
}
35213521

35223522
res = internal_connect(s, SAS2SA(&addrbuf), addrlen, 0);
3523-
if (res < 0)
3523+
if (res == -1)
35243524
return NULL;
35253525

35263526
return PyLong_FromLong((long) res);

0 commit comments

Comments
 (0)