Merging upstream version 2.3.1.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-04-24 14:04:25 +02:00
parent f3ce14142a
commit 685d423929
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
12 changed files with 206 additions and 42 deletions

View file

@ -175,10 +175,10 @@ int pcapdump_open(my_bpftimeval ts)
ts.tv_sec++;
ts.tv_usec -= MILLION;
}
gmtime_r((time_t*)&ts.tv_sec, &tm);
gmtime_r(&ts.tv_sec, &tm);
strftime(sbuf, 64, "%Y%m%d.%H%M%S", &tm);
if (asprintf(&dumpname, "%s.%s.%06lu",
dump_base, sbuf, (u_long)ts.tv_usec)
if (asprintf(&dumpname, "%s.%s.%06" PRI_tv_usec,
dump_base, sbuf, ts.tv_usec)
< 0
|| asprintf(&dumpnamepart, "%s.part", dumpname) < 0) {
logerr("asprintf: %s", strerror(errno));

View file

@ -286,7 +286,7 @@ void rssm_save_counts(const char* sbuf)
FILE* fp;
int i;
char* tbuf = 0;
i = asprintf(&tbuf, "%s.%s.%06lu", counts_prefix ? counts_prefix : COUNTS_PREFIX_DEFAULT, sbuf, (u_long)open_ts.tv_usec);
i = asprintf(&tbuf, "%s.%s.%06" PRI_tv_usec, counts_prefix ? counts_prefix : COUNTS_PREFIX_DEFAULT, sbuf, open_ts.tv_usec);
if (i < 1 || !tbuf) {
logerr("asprintf: out of memory");
return;
@ -302,7 +302,7 @@ void rssm_save_counts(const char* sbuf)
char tz[21];
struct tm tm;
gmtime_r((time_t*)&open_ts.tv_sec, &tm);
gmtime_r(&open_ts.tv_sec, &tm);
if (!strftime(tz, sizeof(tz), "%Y-%m-%dT%H:%M:%SZ", &tm)) {
logerr("rssm: strftime failed");
fclose(fp);
@ -443,8 +443,8 @@ void rssm_save_counts(const char* sbuf)
}
}
} else {
fprintf(fp, "first-packet-time %ld\n", (long)open_ts.tv_sec);
fprintf(fp, "last-packet-time %ld\n", (long)close_ts.tv_sec);
fprintf(fp, "first-packet-time %" PRI_tv_sec "\n", open_ts.tv_sec);
fprintf(fp, "last-packet-time %" PRI_tv_sec "\n", close_ts.tv_sec);
fprintf(fp, "dns-udp-queries-received-ipv4 %" PRIu64 "\n", counts.dns_udp_queries_received_ipv4);
fprintf(fp, "dns-udp-queries-received-ipv6 %" PRIu64 "\n", counts.dns_udp_queries_received_ipv6);
fprintf(fp, "dns-tcp-queries-received-ipv4 %" PRIu64 "\n", counts.dns_tcp_queries_received_ipv4);
@ -510,7 +510,7 @@ void rssm_save_sources(const char* sbuf)
FILE* fp;
char* tbuf = 0;
int i;
i = asprintf(&tbuf, "%s.%s.%06lu", sources_prefix, sbuf, (u_long)open_ts.tv_usec);
i = asprintf(&tbuf, "%s.%s.%06" PRI_tv_usec, sources_prefix, sbuf, open_ts.tv_usec);
if (i < 1 || !tbuf) {
logerr("asprintf: out of memory");
return;
@ -535,7 +535,7 @@ void rssm_save_aggregated(const char* sbuf)
FILE* fp;
char* tbuf = 0;
int i;
i = asprintf(&tbuf, "%s.%s.%06lu", aggregated_prefix, sbuf, (u_long)open_ts.tv_usec);
i = asprintf(&tbuf, "%s.%s.%06" PRI_tv_usec, aggregated_prefix, sbuf, open_ts.tv_usec);
if (i < 1 || !tbuf) {
logerr("asprintf: out of memory");
return;
@ -566,7 +566,7 @@ int rssm_close(my_bpftimeval ts)
struct tm tm;
if (dont_fork_on_close) {
gmtime_r((time_t*)&open_ts.tv_sec, &tm);
gmtime_r(&open_ts.tv_sec, &tm);
strftime(sbuf, sizeof(sbuf), "%Y%m%d.%H%M%S", &tm);
close_ts = ts;
rssm_save_counts(sbuf);
@ -596,7 +596,7 @@ int rssm_close(my_bpftimeval ts)
exit(0);
}
/* grandchild (2nd gen) continues */
gmtime_r((time_t*)&open_ts.tv_sec, &tm);
gmtime_r(&open_ts.tv_sec, &tm);
strftime(sbuf, sizeof(sbuf), "%Y%m%d.%H%M%S", &tm);
close_ts = ts;
rssm_save_counts(sbuf);

View file

@ -290,8 +290,8 @@ void rzkeychange_submit_counts(void)
double elapsed = (double)clos_ts.tv_sec - (double)open_ts.tv_sec + 0.000001 * clos_ts.tv_usec - 0.000001 * open_ts.tv_usec; // NOSONAR
int k;
k = snprintf(qname, sizeof(qname), "%lu-%u-%" PRIu64 "-%" PRIu64 "-%" PRIu64 "-%" PRIu64 "-%" PRIu64 "-%" PRIu64 "-%" PRIu64 ".%s.%s.%s",
(u_long)open_ts.tv_sec,
k = snprintf(qname, sizeof(qname), "%" PRI_tv_sec "-%u-%" PRIu64 "-%" PRIu64 "-%" PRIu64 "-%" PRIu64 "-%" PRIu64 "-%" PRIu64 "-%" PRIu64 ".%s.%s.%s",
open_ts.tv_sec,
(unsigned int)(elapsed + 0.5),
counts.total,
counts.dnskey,
@ -330,8 +330,8 @@ void rzkeychange_submit_counts(void)
if (*t == '.' || *t == ':')
*t = '-';
k = snprintf(qname, sizeof(qname), "%lu.%s.%hhx.%s.%s.%s.%s",
(u_long)open_ts.tv_sec,
k = snprintf(qname, sizeof(qname), "%" PRI_tv_sec ".%s.%hhx.%s.%s.%s.%s",
open_ts.tv_sec,
s,
key_tag_signals[i].flags,
key_tag_signals[i].signal,

View file

@ -220,7 +220,7 @@ void txtout_output(const char* descr, iaddr from, iaddr to, uint8_t proto, unsig
/*
* IP Stuff
*/
fprintf(out, "%10ld.%06ld", (long)ts.tv_sec, (long)ts.tv_usec);
fprintf(out, "%10" PRI_tv_sec ".%06" PRI_tv_usec, ts.tv_sec, ts.tv_usec);
fprintf(out, " %s %u", ia_str(from), sport);
fprintf(out, " %s %u", ia_str(to), dport);
fprintf(out, " %hhu", proto);