Skip to content

Commit

Permalink
Also check uppper bound
Browse files Browse the repository at this point in the history
  • Loading branch information
ifduyue committed Dec 10, 2015
1 parent 405c5c2 commit fdf7456
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import setup, Extension
import os

VERSION = "1.0"
VERSION = "1.0.1"

if os.name == 'posix':
extra_compile_args = [
Expand Down
7 changes: 4 additions & 3 deletions xxtea.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,20 +141,21 @@ static int longs2bytes(uint32_t *in, int inlen, char *out, int padding)
s[4 * i + 3] = (in[i] >> 24) & 0xFF;
}

i *= 4;
i <<= 2;

/* PKCS#7 unpadding */
if (padding) {
pad = s[i - 1];
i -= pad;
}

if (i >= 0) {
if (i >= 0 && i <= inlen << 2) {
s[i] = '\0';
}

/* How many bytes we've got */
return i;
/* Negative means errors */
return pad < 0 ? pad : i;
}

/*****************************************************************************
Expand Down

0 comments on commit fdf7456

Please sign in to comment.