mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-24 04:13:28 +01:00
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. (!)
This commit is contained in:
parent
4d51dcda2f
commit
9c9e07963d
@ -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("<allocation failure>");
|
||||
cp = result;
|
||||
for (i=0;i<len;++i) {
|
||||
*cp++ = "0123456789ABCDEF"[val[i] >> 4];
|
||||
*cp++ = "0123456789ABCDEF"[val[i] & 0x0f];
|
||||
}
|
||||
while (ellipses--)
|
||||
*cp++ = '.';
|
||||
*cp = 0;
|
||||
return result;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user