kopia lustrzana https://gitlab.com/sane-project/backends
Prevent possible buffer overflows [-Wstrncat-size]. Fixes 315198
rodzic
18e4c4a086
commit
06b865cfd2
|
@ -929,6 +929,7 @@ HexDump (int debugLevel, const unsigned char *buf, size_t bufSize)
|
||||||
{
|
{
|
||||||
|
|
||||||
unsigned int i, j;
|
unsigned int i, j;
|
||||||
|
size_t lineBufFree;
|
||||||
|
|
||||||
char itemBuf[16] = { 0 }, lineBuf[256] = { 0 };
|
char itemBuf[16] = { 0 }, lineBuf[256] = { 0 };
|
||||||
|
|
||||||
|
@ -943,7 +944,8 @@ HexDump (int debugLevel, const unsigned char *buf, size_t bufSize)
|
||||||
|
|
||||||
sprintf (itemBuf, "%02x ", (const unsigned int) buf[i]);
|
sprintf (itemBuf, "%02x ", (const unsigned int) buf[i]);
|
||||||
|
|
||||||
strncat (lineBuf, itemBuf, sizeof (lineBuf));
|
lineBufFree = sizeof (lineBuf) - strlen (lineBuf) - 1;
|
||||||
|
strncat (lineBuf, itemBuf, lineBufFree);
|
||||||
|
|
||||||
if ((i + 1) % 16)
|
if ((i + 1) % 16)
|
||||||
continue;
|
continue;
|
||||||
|
@ -960,7 +962,8 @@ HexDump (int debugLevel, const unsigned char *buf, size_t bufSize)
|
||||||
{
|
{
|
||||||
sprintf (itemBuf, ".");
|
sprintf (itemBuf, ".");
|
||||||
}
|
}
|
||||||
strncat (lineBuf, itemBuf, sizeof (lineBuf));
|
lineBufFree = sizeof (lineBuf) - strlen (lineBuf) - 1;
|
||||||
|
strncat (lineBuf, itemBuf, lineBufFree);
|
||||||
|
|
||||||
} /* for j */
|
} /* for j */
|
||||||
|
|
||||||
|
@ -974,7 +977,8 @@ HexDump (int debugLevel, const unsigned char *buf, size_t bufSize)
|
||||||
|
|
||||||
for (j = (i % 16); j < 16; ++j)
|
for (j = (i % 16); j < 16; ++j)
|
||||||
{
|
{
|
||||||
strncat (lineBuf, " ", sizeof (lineBuf));
|
lineBufFree = sizeof (lineBuf) - strlen (lineBuf) - 1;
|
||||||
|
strncat (lineBuf, " ", lineBufFree);
|
||||||
}
|
}
|
||||||
for (j = 1 + i - ((i + 1) % 16); j < i; ++j)
|
for (j = 1 + i - ((i + 1) % 16); j < i; ++j)
|
||||||
{
|
{
|
||||||
|
@ -986,7 +990,8 @@ HexDump (int debugLevel, const unsigned char *buf, size_t bufSize)
|
||||||
{
|
{
|
||||||
strcpy (itemBuf, ".");
|
strcpy (itemBuf, ".");
|
||||||
}
|
}
|
||||||
strncat (lineBuf, itemBuf, sizeof (lineBuf));
|
lineBufFree = sizeof (lineBuf) - strlen (lineBuf) - 1;
|
||||||
|
strncat (lineBuf, itemBuf, lineBufFree);
|
||||||
}
|
}
|
||||||
DBG (debugLevel, "%s\n", lineBuf);
|
DBG (debugLevel, "%s\n", lineBuf);
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue