From 88f46b162b3bf9bc9a7a1d3d7280f702f5b9f501 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 5 Jul 2012 20:14:49 +0200 Subject: Fix potential integer overflow in bin2hex The code was already using safe_emalloc but did the multiplication in the first argument, thus making the use of safe_emalloc pretty useless. The *2 is now moved to the second argument. --- ext/standard/string.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/standard/string.c b/ext/standard/string.c index e3fc27e7e2..a521d78261 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -131,7 +131,7 @@ static char *php_bin2hex(const unsigned char *old, const size_t oldlen, size_t * register unsigned char *result = NULL; size_t i, j; - result = (unsigned char *) safe_emalloc(oldlen * 2, sizeof(char), 1); + result = (unsigned char *) safe_emalloc(oldlen, 2 * sizeof(char), 1); for (i = j = 0; i < oldlen; i++) { result[j++] = hexconvtab[old[i] >> 4]; -- cgit v1.2.1