]> git.ipfire.org Git - thirdparty/pciutils.git/commit
Use snprintf instead of sprintf to prevent buffer overruns
authorMingjie Shen <shen497@purdue.edu>
Wed, 18 Jun 2025 21:47:28 +0000 (17:47 -0400)
committerMartin Mareš <mj@ucw.cz>
Sat, 21 Jun 2025 15:14:42 +0000 (17:14 +0200)
commita213399f8f2929f0f275660625f5e817baf8b3c6
tree7a5fc13caffe309dc198c1edaaa2cc9b1c0be8fb
parentdecf729833fc6f74e0279410b40ee40df85c216f
Use snprintf instead of sprintf to prevent buffer overruns

In bitops.h, update the TABLE macro to call snprintf(buf, sizeof(buf),
...) rather than unbounded sprintf, ensuring that out-of-range indices
produce a bounded "??%d" string.

In setpci.c, change the device slot formatting from sprintf(slot, ...) to
snprintf(slot, sizeof(slot), ...), capping output to the 16-byte buffer
and avoiding overflow when printing PCI domain, bus, dev, and func
values.

Signed-off-by: Mingjie Shen <shen497@purdue.edu>
bitops.h
setpci.c