From: Nick Mathewson Date: Sat, 19 Apr 2014 16:44:31 +0000 (-0400) Subject: scan-build: truncate tinytest hexified outputs to 1024 bytes. X-Git-Tag: tor-0.2.5.4-alpha~14^2~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9c9e07963dddff6e11330e9dc8ad7a6d37da4aa4;p=thirdparty%2Ftor.git scan-build: truncate tinytest hexified outputs to 1024 bytes. scan-build didn't like the unlimited version since we might need to overflow size_t to hexify a string that took up half our address space. (!) --- diff --git a/src/ext/tinytest.c b/src/ext/tinytest.c index 3a8e331055..cc054ad340 100644 --- a/src/ext/tinytest.c +++ b/src/ext/tinytest.c @@ -478,16 +478,23 @@ tinytest_format_hex_(const void *val_, unsigned long len) const unsigned char *val = val_; char *result, *cp; size_t i; + int ellipses = 0; if (!val) return strdup("null"); - if (!(result = malloc(len*2+1))) + if (len > 1024) { + ellipses = 3; + len = 1024; + } + if (!(result = malloc(len*2+4))) return strdup(""); cp = result; for (i=0;i> 4]; *cp++ = "0123456789ABCDEF"[val[i] & 0x0f]; } + while (ellipses--) + *cp++ = '.'; *cp = 0; return result; }