Skip to content

Commit a28398e

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

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

39343934
PySSL_END_ALLOW_THREADS_S(pw_info->thread_state);
39353935

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

0 commit comments

Comments
 (0)