diff options
Diffstat (limited to 'ext/Digest/MD5/MD5.xs')
-rw-r--r-- | ext/Digest/MD5/MD5.xs | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/ext/Digest/MD5/MD5.xs b/ext/Digest/MD5/MD5.xs index 1abe4c429c..a89bbd7b8e 100644 --- a/ext/Digest/MD5/MD5.xs +++ b/ext/Digest/MD5/MD5.xs @@ -153,7 +153,7 @@ typedef struct { * padding is also the reason the buffer in MD5_CTX have to be * 128 bytes. */ -static unsigned char PADDING[64] = { +static const unsigned char PADDING[64] = { 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 @@ -484,7 +484,7 @@ static MD5_CTX* get_md5_ctx(pTHX_ SV* sv) static char* hex_16(const unsigned char* from, char* to) { - static char *hexdigits = "0123456789abcdef"; + static const char hexdigits[] = "0123456789abcdef"; const unsigned char *end = from + 16; char *d = to; @@ -499,7 +499,7 @@ static char* hex_16(const unsigned char* from, char* to) static char* base64_16(const unsigned char* from, char* to) { - static char* base64 = + static const char base64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; const unsigned char *end = from + 16; unsigned char c1, c2, c3; @@ -626,10 +626,18 @@ addfile(self, fh) PREINIT: MD5_CTX* context = get_md5_ctx(aTHX_ self); STRLEN fill = context->bytes_low & 0x3F; +#ifdef USE_HEAP_INSTEAD_OF_STACK + unsigned char* buffer; +#else unsigned char buffer[4096]; +#endif int n; CODE: if (fh) { +#ifdef USE_HEAP_INSTEAD_OF_STACK + New(0, buffer, 4096, unsigned char); + assert(buffer); +#endif if (fill) { /* The MD5Update() function is faster if it can work with * complete blocks. This will fill up any buffered block @@ -646,7 +654,9 @@ addfile(self, fh) while ( (n = PerlIO_read(fh, buffer, sizeof(buffer))) > 0) { MD5Update(context, buffer, n); } - +#ifdef USE_HEAP_INSTEAD_OF_STACK + Safefree(buffer); +#endif if (PerlIO_error(fh)) { croak("Reading from filehandle failed"); } |