summaryrefslogtreecommitdiff
path: root/src/_counter.c
diff options
context:
space:
mode:
authorDwayne Litzenberger <dwon@hedgehog.dlitz.net>2008-11-05 16:26:54 -0500
committerDwayne Litzenberger <dwon@hedgehog.dlitz.net>2008-11-05 16:35:25 -0500
commit28587232cc5a14ec2d1cb6d49f2fcf5973b5e986 (patch)
tree815c631cafdf6c77a99d8b95d4d870d6b35fa467 /src/_counter.c
parent2cc35123e0b3344c0d6cc23cc0b3bebe8d972fe5 (diff)
downloadpycrypto-28587232cc5a14ec2d1cb6d49f2fcf5973b5e986.tar.gz
Counter: Fix segfault on 64-bit machines when calling .get_value() on a little-endian counter
.get_value() iterates throught the bytes from left-to-right (increment = 1) for big-endian counters, and right-to-left (increment = -1) for little-endian counters. Since we had declared the "increment" variable as "unsigned int", we instead were adding 2^32-1 to a pointer. This achieved the desired result on 32-bit machines, where pointers are also 32 bits, but caused a crash on 64-bit machines.
Diffstat (limited to 'src/_counter.c')
-rw-r--r--src/_counter.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/_counter.c b/src/_counter.c
index 91d0316..1aaafee 100644
--- a/src/_counter.c
+++ b/src/_counter.c
@@ -127,7 +127,8 @@ CounterObject_dealloc(PCT_CounterObject *self)
static inline PyObject *
_CounterObject_next_value(PCT_CounterObject *self, int little_endian)
{
- unsigned int i, increment;
+ unsigned int i;
+ int increment;
uint8_t *p;
PyObject *eight = NULL;
PyObject *ch = NULL;