Skip to content

Commit 11e0523

Browse files
committed
ssl: Raise OSError for ERR_LIB_SYS
From the ERR_raise manpage: ERR_LIB_SYS This "library code" indicates that a system error is being reported. In this case, the reason code given to `ERR_raise()` and `ERR_raise_data()` *must* be `errno(3)`.
1 parent db5c576 commit 11e0523

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Modules/_ssl.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,11 @@ PySSL_SetError(PySSLSocket *sslsock, const char *filename, int lineno)
667667
ERR_GET_REASON(e) == SSL_R_CERTIFICATE_VERIFY_FAILED) {
668668
type = state->PySSLCertVerificationErrorObject;
669669
}
670+
if (ERR_GET_LIB(e) == ERR_LIB_SYS) {
671+
// A system error is being reported; reason is set to errno
672+
errno = ERR_GET_REASON(e);
673+
return PyErr_SetFromErrno(PyExc_OSError);
674+
}
670675
p = PY_SSL_ERROR_SYSCALL;
671676
}
672677
break;
@@ -692,6 +697,11 @@ PySSL_SetError(PySSLSocket *sslsock, const char *filename, int lineno)
692697
errstr = "EOF occurred in violation of protocol";
693698
}
694699
#endif
700+
if (ERR_GET_LIB(e) == ERR_LIB_SYS) {
701+
// A system error is being reported; reason is set to errno
702+
errno = ERR_GET_REASON(e);
703+
return PyErr_SetFromErrno(PyExc_OSError);
704+
}
695705
break;
696706
}
697707
default:

0 commit comments

Comments
 (0)