[PATCH v10 00/18] fix format overflow warnings in libraries

Stephen Hemminger
2026-01-13T20:23:36Z

This series fixes format overflow warnings that occur when building
DPDK libraries with -Wformat-overflow enabled. The final patch in
the series removes the -Wno-format-truncation flag from lib/meson.build,
enabling these warnings by default.

The changes fall into several categories:

1. Add explicit name length validation to APIs that create named objects
(lpm, hash, efd, tailq, cfgfile). These now return ENAMETOOLONG
instead of silently truncating names.

2. Check snprintf() return values and log warnings when truncation
occurs in non-fatal cases (thread names, xstat names, ring names).

3. Use asprintf() for dynamic allocation where fixed buffers are
insufficient (graph pcap comments, hugepage paths, plugin paths).

4. Increase buffer sizes where the existing size was too small
(telemetry address strings, cfgfile line buffer).

5. Replace PATH_MAX with UNIX_PATH_MAX for unix domain socket paths
since the actual limit is 108 characters, not 4096.

6. Use standard C library functions where appropriate (getmntent_r
for parsing /proc/mounts).

All API changes are documented in the release notes under a single
entry describing the new name length checks.

v10:
- Fixed inconsistent comparison in eal thread name warning
(now uses RTE_THREAD_NAME_SIZE on all platforms)
- Fixed typo "peerr" -> "peer" in eal_common_proc.c

Stephen Hemminger (18):
lpm: restrict name size
hash: add checks for hash name length
graph: avoid overflowing comment buffer
latencystats: add check for string overflow
telemetry: check for path overflow
efd: handle possible name truncation
eal: use C library to parse filesystem table
eal: warn if thread name is truncated
eal: avoid format overflow when handling addresses
eal: add check for sysfs path overflow
eal: limit maximum runtime directory and socket paths
eal: check for hugefile path overflow
eal: check tailq length
eal: handle long shared library path
ethdev: avoid possible overflow in xstat names
vhost: check for overflow in xstat name
cfgfile: add length checks and increase line buffer
lib: enable format overflow warnings

app/test/test_hash.c | 21 ++++++
doc/guides/rel_notes/release_26_03.rst | 13 ++++
lib/cfgfile/rte_cfgfile.c | 43 ++++++++---
lib/cfgfile/rte_cfgfile.h | 6 +-
lib/eal/common/eal_common_config.c | 6 +-
lib/eal/common/eal_common_memory.c | 2 +-
lib/eal/common/eal_common_options.c | 17 +++--
lib/eal/common/eal_common_proc.c | 85 ++++++++++++++--------
lib/eal/common/eal_common_tailqs.c | 13 +++-
lib/eal/common/eal_filesystem.h | 27 +++++--
lib/eal/freebsd/eal.c | 6 +-
lib/eal/linux/eal.c | 6 +-
lib/eal/linux/eal_hugepage_info.c | 98 ++++++++++++--------------
lib/eal/linux/eal_memalloc.c | 11 ++-
lib/eal/linux/eal_memory.c | 9 ++-
lib/eal/windows/eal.c | 6 +-
lib/efd/rte_efd.c | 18 +++--
lib/ethdev/rte_ethdev.c | 35 ++++++---
lib/graph/graph_pcap.c | 9 ++-
lib/hash/rte_cuckoo_hash.c | 41 +++++++----
lib/hash/rte_fbk_hash.c | 12 +++-
lib/hash/rte_fbk_hash.h | 1 +
lib/latencystats/rte_latencystats.c | 9 ++-
lib/lpm/rte_lpm.c | 16 +++--
lib/lpm/rte_lpm.h | 1 +
lib/meson.build | 4 --
lib/telemetry/telemetry_legacy.c | 7 +-
lib/vhost/vhost.c | 14 ++--
28 files changed, 368 insertions(+), 168 deletions(-)

--
2.51.0