[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r18586: {torvm} Fix size check in base16encode and make builds happy for bui (torvm/trunk/build/win32/src/torvm-w32)
Author: coderman
Date: 2009-02-17 05:38:46 -0500 (Tue, 17 Feb 2009)
New Revision: 18586
Modified:
torvm/trunk/build/win32/src/torvm-w32/apicommon.c
Log:
Fix size check in base16encode and make builds happy for buildbot until bundle merge finished.
Modified: torvm/trunk/build/win32/src/torvm-w32/apicommon.c
===================================================================
--- torvm/trunk/build/win32/src/torvm-w32/apicommon.c 2009-02-17 06:40:51 UTC (rev 18585)
+++ torvm/trunk/build/win32/src/torvm-w32/apicommon.c 2009-02-17 10:38:46 UTC (rev 18586)
@@ -289,15 +289,18 @@
char ** hexstr)
{
BOOL retval = FALSE;
- DWORD olen = 0;
+ int olen = 0;
*hexstr = NULL;
DWORD i;
- if (len >= (DWORD)(float)(olen-1)/2) {
- lerror ("Bogus call to base16encode with length: %ld.", len);
+ /* sanity check long before we need to worry about int overflow... */
+#define BASE16BUF_MAXSIZE (1024*1024)
+ if ((unsigned long)len > BASE16BUF_MAXSIZE) {
+ lerror ("Bogus call to base16encode with length: %ld. Over sanity limit of %ld", len, BASE16BUF_MAXSIZE);
return FALSE;
}
olen = len * 2 + 1;
- if (! *hexstr = malloc(olen)) {
+ *hexstr = malloc(olen);
+ if (NULL == *hexstr) {
lerror ("base16encode malloc failed with length: %ld.", olen);
return FALSE;
}