mirror of https://github.com/OISF/suricata
log/pcap: improve path handling
Use proper path merging.
Address format truncation warnings.
log-pcap.c: In function 'PcapLogInitRingBuffer':
log-pcap.c:970:13: warning: '%s' directive output may be truncated writing up to 255 bytes into a region of size between 0 and 4095 [-Wformat-truncation=]
970 | if (snprintf(path, PATH_MAX, "%s/%s", pattern, entry->d_name) == PATH_MAX)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
log-pcap.c:970:13: note: 'snprintf' output between 2 and 4352 bytes into a destination of size 4096
log-pcap.c: In function 'PcapLogOpenFileCtx':
log-pcap.c:1796:56: warning: '%s' directive output may be truncated writing likely 1 or more bytes into a region of size between 0 and 4095 [-Wformat-truncation=]
1796 | ret = snprintf(filename, PATH_MAX, "%s/%s.%u.%" PRIu32 ".%" PRIu32 "%s", pl->dir,
| ^~
log-pcap.c:1796:52: note: assuming directive output of 1 byte
1796 | ret = snprintf(filename, PATH_MAX, "%s/%s.%u.%" PRIu32 ".%" PRIu32 "%s", pl->dir,
| ^~~~~~~~~~~~
log-pcap.c:1796:52: note: using the range [0, 4294967295] for directive argument
log-pcap.c:1796:52: note: directive argument in the range [0, 1048575]
log-pcap.c:1796:52: note: assuming directive output of 1 byte
log-pcap.c:1796:23: note: 'snprintf' output 8 or more bytes (assuming 4111) into a destination of size 4096
1796 | ret = snprintf(filename, PATH_MAX, "%s/%s.%u.%" PRIu32 ".%" PRIu32 "%s", pl->dir,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1797 | pl->prefix, pl->thread_number, (uint32_t)SCTIME_SECS(ts),
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1798 | (uint32_t)SCTIME_USECS(ts), pl->suffix);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
log-pcap.c:1793:56: warning: '%s' directive output may be truncated writing likely 1 or more bytes into a region of size between 0 and 4095 [-Wformat-truncation=]
1793 | ret = snprintf(filename, PATH_MAX, "%s/%s.%u.%" PRIu32 "%s", pl->dir, pl->prefix,
| ^~
log-pcap.c:1793:52: note: assuming directive output of 1 byte
1793 | ret = snprintf(filename, PATH_MAX, "%s/%s.%u.%" PRIu32 "%s", pl->dir, pl->prefix,
| ^~~~~~~~~~~~
log-pcap.c:1793:52: note: using the range [0, 4294967295] for directive argument
log-pcap.c:1793:52: note: assuming directive output of 1 byte
log-pcap.c:1793:23: note: 'snprintf' output 6 or more bytes (assuming 4103) into a destination of size 4096
1793 | ret = snprintf(filename, PATH_MAX, "%s/%s.%u.%" PRIu32 "%s", pl->dir, pl->prefix,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1794 | pl->thread_number, (uint32_t)SCTIME_SECS(ts), pl->suffix);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
log-pcap.c:1738:52: warning: '%s' directive output may be truncated writing likely 1 or more bytes into a region of size between 0 and 4095 [-Wformat-truncation=]
1738 | ret = snprintf(filename, PATH_MAX, "%s/%s.%" PRIu32 ".%" PRIu32 "%s", pl->dir,
| ^~
log-pcap.c:1738:48: note: assuming directive output of 1 byte
1738 | ret = snprintf(filename, PATH_MAX, "%s/%s.%" PRIu32 ".%" PRIu32 "%s", pl->dir,
| ^~~~~~~~~
log-pcap.c:1738:48: note: using the range [0, 4294967295] for directive argument
log-pcap.c:1738:48: note: directive argument in the range [0, 1048575]
log-pcap.c:1738:48: note: assuming directive output of 1 byte
log-pcap.c:1738:19: note: 'snprintf' output 6 or more bytes (assuming 4109) into a destination of size 4096
1738 | ret = snprintf(filename, PATH_MAX, "%s/%s.%" PRIu32 ".%" PRIu32 "%s", pl->dir,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1739 | pl->prefix, (uint32_t)SCTIME_SECS(ts), (uint32_t)SCTIME_USECS(ts), pl->suffix);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
log-pcap.c:1735:52: warning: '%s' directive output may be truncated writing likely 1 or more bytes into a region of size between 0 and 4095 [-Wformat-truncation=]
1735 | ret = snprintf(filename, PATH_MAX, "%s/%s.%" PRIu32 "%s", pl->dir, pl->prefix,
| ^~
log-pcap.c:1735:48: note: assuming directive output of 1 byte
1735 | ret = snprintf(filename, PATH_MAX, "%s/%s.%" PRIu32 "%s", pl->dir, pl->prefix,
| ^~~~~~~~~
log-pcap.c:1735:48: note: using the range [0, 4294967295] for directive argument
log-pcap.c:1735:48: note: assuming directive output of 1 byte
log-pcap.c:1735:19: note: 'snprintf' output 4 or more bytes (assuming 4101) into a destination of size 4096
1735 | ret = snprintf(filename, PATH_MAX, "%s/%s.%" PRIu32 "%s", pl->dir, pl->prefix,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1736 | (uint32_t)SCTIME_SECS(ts), pl->suffix);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ticket: #7905.
pull/13926/head
parent
3d0d7b740e
commit
98730c2c43
Loading…
Reference in New Issue