Fixed snprintf return value checks
This commit is contained in:
parent
2dfc1ddb12
commit
507722aca4
@ -107,8 +107,11 @@ void BitDump(const char* tag, UINT32 level, const BYTE* buffer, UINT32 length, U
|
|||||||
{
|
{
|
||||||
const char* str = strs[buffer[i / 8]];
|
const char* str = strs[buffer[i / 8]];
|
||||||
const int nbits = (length - i) > 8 ? 8 : (length - i);
|
const int nbits = (length - i) > 8 ? 8 : (length - i);
|
||||||
pos += _snprintf(&pbuffer[pos], length - pos, "%.*s ", nbits, str);
|
const int rc = _snprintf(&pbuffer[pos], length - pos, "%.*s ", nbits, str);
|
||||||
|
if (rc < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
pos += (size_t)rc;
|
||||||
if ((i % 64) == 0)
|
if ((i % 64) == 0)
|
||||||
{
|
{
|
||||||
pos = 0;
|
pos = 0;
|
||||||
|
@ -151,13 +151,19 @@ void winpr_CArrayDump(const char* tag, UINT32 level, const BYTE* data, size_t le
|
|||||||
pos = 0;
|
pos = 0;
|
||||||
|
|
||||||
for (i = 0; i < line; i++)
|
for (i = 0; i < line; i++)
|
||||||
pos += _snprintf(&buffer[pos], llen - pos, "\\x%02" PRIX8 "", p[i]);
|
{
|
||||||
|
const int rc = _snprintf(&buffer[pos], llen - pos, "\\x%02" PRIX8 "", p[i]);
|
||||||
|
if (rc < 0)
|
||||||
|
goto fail;
|
||||||
|
pos += (size_t)rc;
|
||||||
|
}
|
||||||
|
|
||||||
WLog_LVL(tag, level, "%s", buffer);
|
WLog_LVL(tag, level, "%s", buffer);
|
||||||
offset += line;
|
offset += line;
|
||||||
p += line;
|
p += line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fail:
|
||||||
free(buffer);
|
free(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user