Skip to content

Commit a188bd4

Browse files
bpo-43789: OpenSSL 3.0.0 Don't call passwd callback again in error case (GH-25303)
(cherry picked from commit d3b73f3) Co-authored-by: Christian Heimes <[email protected]>
1 parent 4d9336d commit a188bd4

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
@@ -3931,6 +3931,13 @@ _password_callback(char *buf, int size, int rwflag, void *userdata)
39313931

39323932
PySSL_END_ALLOW_THREADS_S(pw_info->thread_state);
39333933

3934+
if (pw_info->error) {
3935+
/* already failed previously. OpenSSL 3.0.0-alpha14 invokes the
3936+
* callback multiple times which can lead to fatal Python error in
3937+
* exception check. */
3938+
goto error;
3939+
}
3940+
39343941
if (pw_info->callable) {
39353942
fn_ret = _PyObject_CallNoArg(pw_info->callable);
39363943
if (!fn_ret) {

0 commit comments

Comments
 (0)