summaryrefslogtreecommitdiff
path: root/src/block_template.c
diff options
context:
space:
mode:
authorDwayne C. Litzenberger <dlitz@dlitz.net>2008-09-16 00:54:36 -0400
committerDwayne C. Litzenberger <dlitz@dlitz.net>2008-09-16 01:01:27 -0400
commit91e07cde56aa135002e774e8655a88836d7797cc (patch)
tree4e710fc1fcf9c0f2c1024dd3034777a5bb0c4212 /src/block_template.c
parentfec685ff8d63dd9dd6dd347c05c8f136f1583c3e (diff)
downloadpycrypto-91e07cde56aa135002e774e8655a88836d7797cc.tar.gz
RC5: Fix buffer overrun and test failures.
Before this fix, the RC5 module would overrun its "L" buffer whenever the specified number of rounds exceeded 49 (the runtime check allowed up to 255 rounds). Also, any time the length of the key was less than a multiple of 4 bytes, the RC5 module would operate incorrectly. This commit fixes both bugs.
Diffstat (limited to 'src/block_template.c')
-rw-r--r--src/block_template.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/block_template.c b/src/block_template.c
index 36e10f7..3710dd1 100644
--- a/src/block_template.c
+++ b/src/block_template.c
@@ -188,10 +188,10 @@ ALGnew(PyObject *self, PyObject *args, PyObject *kwdict)
word_size);
return NULL;
}
- if (rounds<0 || 255<rounds) {
+ if (rounds<0 || MAX_RC5_ROUNDS<rounds) {
PyErr_Format(PyExc_ValueError,
- "RC5: rounds must be between 0 and 255, not %i",
- rounds);
+ "RC5: rounds must be between 0 and %u, not %i",
+ MAX_RC5_ROUNDS, rounds);
return NULL;
}
#endif