-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
gh-145376: Fix null pointer deref in md5module.c #145422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
d5b9513
6cc205c
330128f
aae8d22
c696867
eafcc2d
6b4cbff
3aa0033
fe78d49
4ae295b
3e79541
1fa2e83
46b2511
93f1de5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Fix double free and null pointer dereference in unusual error scenarios in :mod:`md5module` and :mod:`hmacmodule`. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1378,7 +1378,6 @@ static void | |
| py_hmac_hinfo_ht_free(void *hinfo) | ||
| { | ||
| py_hmac_hinfo *entry = (py_hmac_hinfo *)hinfo; | ||
| assert(entry->display_name != NULL); | ||
| if (--(entry->refcnt) == 0) { | ||
| Py_CLEAR(entry->display_name); | ||
| PyMem_Free(hinfo); | ||
|
|
@@ -1457,7 +1456,9 @@ py_hmac_hinfo_ht_new(void) | |
| do { \ | ||
| int rc = py_hmac_hinfo_ht_add(table, KEY, value); \ | ||
| if (rc < 0) { \ | ||
| PyMem_Free(value); \ | ||
| if (value->refcnt == 0) { \ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one is already part of an other PR actually.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Namely: #145321.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer merging PR gh-145321 first since it's older and more complete.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. I am waiting for the other PR and will rebase accordingly.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i just merged the above. |
||
| PyMem_Free(value); \ | ||
| } \ | ||
| goto error; \ | ||
| } \ | ||
| else if (rc == 1) { \ | ||
|
|
@@ -1474,7 +1475,8 @@ py_hmac_hinfo_ht_new(void) | |
| e->hashlib_name == NULL ? e->name : e->hashlib_name | ||
| ); | ||
| if (value->display_name == NULL) { | ||
| PyMem_Free(value); | ||
| /* value is owned by the table (refcnt > 0), so | ||
| _Py_hashtable_destroy() will free it. */ | ||
|
eendebakpt marked this conversation as resolved.
Outdated
|
||
| goto error; | ||
| } | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.