- Issue #3745: Fix hashlib to always reject unicode and non buffer-api
supporting objects as input no matter how it was compiled (built in
implementations or external openssl library).
(backported from a py3k branch)
diff --git a/Modules/md5.c b/Modules/md5.c
index 0e1058f..f6d0e37 100644
--- a/Modules/md5.c
+++ b/Modules/md5.c
@@ -321,10 +321,10 @@
}
void
-md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes)
+md5_append(md5_state_t *pms, const md5_byte_t *data, unsigned int nbytes)
{
const md5_byte_t *p = data;
- int left = nbytes;
+ unsigned int left = nbytes;
int offset = (pms->count[0] >> 3) & 63;
md5_word_t nbits = (md5_word_t)(nbytes << 3);
@@ -333,7 +333,7 @@
/* this special case is handled recursively */
if (nbytes > INT_MAX - offset) {
- int overlap;
+ unsigned int overlap;
/* handle the append in two steps to prevent overflow */
overlap = 64 - offset;
@@ -351,7 +351,7 @@
/* Process an initial partial block. */
if (offset) {
- int copy = (offset + nbytes > 64 ? 64 - offset : nbytes);
+ unsigned int copy = (offset + nbytes > 64 ? 64 - offset : nbytes);
memcpy(pms->buf + offset, p, copy);
if (offset + copy < 64)