Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
gh-145376: Fix crashes in md5module.c
Fix a possible NULL pointer dereference in `md5module.c`.
This can only occur in error paths taken when the interpreter fails to allocate memory.

(cherry-picked from c1d7768)
  • Loading branch information
eendebakpt committed Mar 6, 2026
commit 3b1aa5f1aa8bd5f1d3cf1a8fd09d3e6c432d2b06
5 changes: 4 additions & 1 deletion Modules/md5module.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@
static void
MD5_dealloc(MD5object *ptr)
{
Hacl_Hash_MD5_free(ptr->hash_state);
if (ptr->hash_state != NULL) {
Hacl_Hash_MD5_free(ptr->hash_state);
ptr->hash_state == NULL;

Check warning on line 89 in Modules/md5module.c

View workflow job for this annotation

GitHub Actions / Address sanitizer (ubuntu-24.04)

statement with no effect [-Wunused-value]

Check warning on line 89 in Modules/md5module.c

View workflow job for this annotation

GitHub Actions / Ubuntu SSL tests with OpenSSL (ubuntu-24.04, 3.3.6)

statement with no effect [-Wunused-value]

Check warning on line 89 in Modules/md5module.c

View workflow job for this annotation

GitHub Actions / Ubuntu SSL tests with OpenSSL (ubuntu-24.04, 3.0.19)

statement with no effect [-Wunused-value]

Check warning on line 89 in Modules/md5module.c

View workflow job for this annotation

GitHub Actions / Ubuntu SSL tests with OpenSSL (ubuntu-24.04, 3.5.5)

statement with no effect [-Wunused-value]

Check warning on line 89 in Modules/md5module.c

View workflow job for this annotation

GitHub Actions / Hypothesis tests on Ubuntu

statement with no effect [-Wunused-value]

Check warning on line 89 in Modules/md5module.c

View workflow job for this annotation

GitHub Actions / Ubuntu SSL tests with OpenSSL (ubuntu-24.04, 3.4.4)

statement with no effect [-Wunused-value]

Check warning on line 89 in Modules/md5module.c

View workflow job for this annotation

GitHub Actions / Ubuntu SSL tests with OpenSSL (ubuntu-24.04, 3.6.1)

statement with no effect [-Wunused-value]

Check warning on line 89 in Modules/md5module.c

View workflow job for this annotation

GitHub Actions / Ubuntu SSL tests with OpenSSL (ubuntu-24.04, 1.1.1w)

statement with no effect [-Wunused-value]

Check warning on line 89 in Modules/md5module.c

View workflow job for this annotation

GitHub Actions / Windows / build (arm64)

'==': result of expression not used; did you intend '='? [D:\a\cpython\cpython\PCbuild\pythoncore.vcxproj]

Check warning on line 89 in Modules/md5module.c

View workflow job for this annotation

GitHub Actions / Windows / build and test (x64)

'==': result of expression not used; did you intend '='? [D:\a\cpython\cpython\PCbuild\pythoncore.vcxproj]

Check warning on line 89 in Modules/md5module.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / build (arm64)

'==': result of expression not used; did you intend '='? [D:\a\cpython\cpython\PCbuild\pythoncore.vcxproj]

Check warning on line 89 in Modules/md5module.c

View workflow job for this annotation

GitHub Actions / Ubuntu / build and test (ubuntu-24.04)

statement with no effect [-Wunused-value]

Check warning on line 89 in Modules/md5module.c

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / build and test (x64)

'==': result of expression not used; did you intend '='? [D:\a\cpython\cpython\PCbuild\pythoncore.vcxproj]

Check warning on line 89 in Modules/md5module.c

View workflow job for this annotation

GitHub Actions / Ubuntu (free-threading) / build and test (ubuntu-24.04)

statement with no effect [-Wunused-value]

Check warning on line 89 in Modules/md5module.c

View workflow job for this annotation

GitHub Actions / Ubuntu / build and test (ubuntu-24.04-arm)

statement with no effect [-Wunused-value]

Check warning on line 89 in Modules/md5module.c

View workflow job for this annotation

GitHub Actions / Ubuntu (free-threading) / build and test (ubuntu-24.04-arm)

statement with no effect [-Wunused-value]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line should be: ptr->hash_state = NULL;

Comment thread
eendebakpt marked this conversation as resolved.
Outdated
}
PyTypeObject *tp = Py_TYPE((PyObject*)ptr);
PyObject_GC_UnTrack(ptr);
PyObject_GC_Del(ptr);
Expand Down
Loading