Skip to content

Commit 2833686

Browse files
miss-islingtontiran
authored andcommitted
bpo-43789: OpenSSL 3.0.0 Don't call passwd callback again in error case (pythonGH-25303) (pythonGH-25306)
(cherry picked from commit d3b73f3) Co-authored-by: Christian Heimes <[email protected]>
1 parent 170af1d commit 2833686

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
OpenSSL 3.0.0: Don't call the password callback function a second time when
2+
first call has signaled an error condition.

Modules/_ssl.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3494,6 +3494,13 @@ _password_callback(char *buf, int size, int rwflag, void *userdata)
34943494

34953495
PySSL_END_ALLOW_THREADS_S(pw_info->thread_state);
34963496

3497+
if (pw_info->error) {
3498+
/* already failed previously. OpenSSL 3.0.0-alpha14 invokes the
3499+
* callback multiple times which can lead to fatal Python error in
3500+
* exception check. */
3501+
goto error;
3502+
}
3503+
34973504
if (pw_info->callable) {
34983505
fn_ret = PyObject_CallFunctionObjArgs(pw_info->callable, NULL);
34993506
if (!fn_ret) {

0 commit comments

Comments
 (0)