aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2022-04-04 23:35:32 +0200
committerStefano Brivio <sbrivio@redhat.com>2022-04-05 18:47:04 +0200
commitdbd0a7035c9a7a59f17d1312063ffa7fc3cd6860 (patch)
tree41be6a60791a2f9f9b9fce73a9d7e81841765861
parent54f8bf82460c70e6159cebcecd200fcb450d3674 (diff)
downloadpasst-dbd0a7035c9a7a59f17d1312063ffa7fc3cd6860.tar
passt-dbd0a7035c9a7a59f17d1312063ffa7fc3cd6860.tar.gz
passt-dbd0a7035c9a7a59f17d1312063ffa7fc3cd6860.tar.bz2
passt-dbd0a7035c9a7a59f17d1312063ffa7fc3cd6860.tar.lz
passt-dbd0a7035c9a7a59f17d1312063ffa7fc3cd6860.tar.xz
passt-dbd0a7035c9a7a59f17d1312063ffa7fc3cd6860.tar.zst
passt-dbd0a7035c9a7a59f17d1312063ffa7fc3cd6860.zip
treewide: Invalid type in argument to printf format specifier, CWE-686
Harmless except for two bad debugging prints. Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r--packet.c6
-rw-r--r--pcap.c6
-rw-r--r--tcp.c38
-rw-r--r--tcp_splice.c14
4 files changed, 32 insertions, 32 deletions
diff --git a/packet.c b/packet.c
index d003640..fa9e9b4 100644
--- a/packet.c
+++ b/packet.c
@@ -53,12 +53,12 @@ void packet_add_do(struct pool *p, size_t len, const char *start,
}
if (len > UINT16_MAX) {
- trace("add packet length %lu, %s:%i", func, line);
+ trace("add packet length %lu, %s:%i", len, func, line);
return;
}
if ((unsigned int)((intptr_t)start - (intptr_t)p->buf) > UINT32_MAX) {
- trace("add packet start %p, buffer start %lu, %s:%i",
+ trace("add packet start %p, buffer start %p, %s:%i",
start, p->buf, func, line);
return;
}
@@ -111,7 +111,7 @@ void *packet_get_do(const struct pool *p, size_t index, size_t offset,
if (len + offset > p->pkt[index].len) {
if (func) {
- trace("data length %lu, offset %lu from length %lu, "
+ trace("data length %lu, offset %lu from length %u, "
"%s:%i", len, offset, p->pkt[index].len,
func, line);
}
diff --git a/pcap.c b/pcap.c
index 296bbb5..64beb34 100644
--- a/pcap.c
+++ b/pcap.c
@@ -88,7 +88,7 @@ void pcap(const char *pkt, size_t len)
h.caplen = h.len = len;
if (write(pcap_fd, &h, sizeof(h)) < 0 || write(pcap_fd, pkt, len) < 0)
- debug("Cannot log packet, length %u", len);
+ debug("Cannot log packet, length %lu", len);
}
/**
@@ -123,7 +123,7 @@ void pcapm(const struct msghdr *mh)
return;
fail:
- debug("Cannot log packet, length %u", iov->iov_len - 4);
+ debug("Cannot log packet, length %lu", iov->iov_len - 4);
}
/**
@@ -161,7 +161,7 @@ void pcapmm(const struct mmsghdr *mmh, unsigned int vlen)
}
return;
fail:
- debug("Cannot log packet, length %u", iov->iov_len - 4);
+ debug("Cannot log packet, length %lu", iov->iov_len - 4);
}
/**
diff --git a/tcp.c b/tcp.c
index 2194067..1409c53 100644
--- a/tcp.c
+++ b/tcp.c
@@ -848,7 +848,7 @@ static void tcp_timer_ctl(const struct ctx *c, struct tcp_conn *conn)
it.it_value.tv_sec = ACT_TIMEOUT;
}
- debug("TCP: index %i, timer expires in %u.%03us", conn - tc,
+ debug("TCP: index %li, timer expires in %lu.%03lus", conn - tc,
it.it_value.tv_sec, it.it_value.tv_nsec / 1000 / 1000);
timerfd_settime(conn->timer, 0, &it, NULL);
@@ -868,14 +868,14 @@ static void conn_flag_do(const struct ctx *c, struct tcp_conn *conn,
return;
conn->flags &= flag;
- debug("TCP: index %i: %s dropped", (conn) - tc,
+ debug("TCP: index %li: %s dropped", conn - tc,
tcp_flag_str[fls(~flag)]);
} else {
if (conn->flags & flag)
return;
conn->flags |= flag;
- debug("TCP: index %i: %s", (conn) - tc,
+ debug("TCP: index %li: %s", conn - tc,
tcp_flag_str[fls(flag)]);
}
@@ -924,12 +924,12 @@ static void conn_event_do(const struct ctx *c, struct tcp_conn *conn,
new += 5;
if (prev != new) {
- debug("TCP: index %i, %s: %s -> %s", (conn) - tc,
+ debug("TCP: index %li, %s: %s -> %s", conn - tc,
num == -1 ? "CLOSED" : tcp_event_str[num],
prev == -1 ? "CLOSED" : tcp_state_str[prev],
(new == -1 || num == -1) ? "CLOSED" : tcp_state_str[new]);
} else {
- debug("TCP: index %i, %s", (conn) - tc,
+ debug("TCP: index %li, %s", conn - tc,
num == -1 ? "CLOSED" : tcp_event_str[num]);
}
@@ -1371,8 +1371,8 @@ static void tcp_hash_insert(const struct ctx *c, struct tcp_conn *conn,
tc_hash[b] = conn;
conn->hash_bucket = b;
- debug("TCP: hash table insert: index %i, sock %i, bucket: %i, next: %p",
- conn - tc, conn->sock, b, CONN_OR_NULL(conn->next_index));
+ debug("TCP: hash table insert: index %li, sock %i, bucket: %i, next: "
+ "%p", conn - tc, conn->sock, b, CONN_OR_NULL(conn->next_index));
}
/**
@@ -1395,7 +1395,7 @@ static void tcp_hash_remove(const struct tcp_conn *conn)
}
}
- debug("TCP: hash table remove: index %i, sock %i, bucket: %i, new: %p",
+ debug("TCP: hash table remove: index %li, sock %i, bucket: %i, new: %p",
conn - tc, conn->sock, b,
prev ? CONN_OR_NULL(prev->next_index) : tc_hash[b]);
}
@@ -1421,7 +1421,7 @@ static void tcp_hash_update(struct tcp_conn *old, struct tcp_conn *new)
}
}
- debug("TCP: hash table update: old index %i, new index %i, sock %i, "
+ debug("TCP: hash table update: old index %li, new index %li, sock %i, "
"bucket: %i, old: %p, new: %p",
old - tc, new - tc, new->sock, b, old, new);
}
@@ -1461,7 +1461,7 @@ static void tcp_table_compact(struct ctx *c, struct tcp_conn *hole)
struct tcp_conn *from, *to;
if ((hole - tc) == --c->tcp.conn_count) {
- debug("TCP: hash table compaction: index %i (%p) was max index",
+ debug("TCP: hash table compaction: maximum index was %li (%p)",
hole - tc, hole);
memset(hole, 0, sizeof(*hole));
return;
@@ -1475,7 +1475,7 @@ static void tcp_table_compact(struct ctx *c, struct tcp_conn *hole)
tcp_epoll_ctl(c, to);
- debug("TCP: hash table compaction: old index %i, new index %i, "
+ debug("TCP: hash table compaction: old index %li, new index %li, "
"sock %i, from: %p, to: %p",
from - tc, to - tc, from->sock, from, to);
@@ -1500,7 +1500,7 @@ static void tcp_conn_destroy(struct ctx *c, struct tcp_conn *conn)
static void tcp_rst_do(struct ctx *c, struct tcp_conn *conn);
#define tcp_rst(c, conn) \
do { \
- debug("TCP: index %i, reset at %s:%i", conn - tc, \
+ debug("TCP: index %li, reset at %s:%i", conn - tc, \
__func__, __LINE__); \
tcp_rst_do(c, conn); \
} while (0)
@@ -2357,7 +2357,7 @@ static int tcp_data_from_sock(struct ctx *c, struct tcp_conn *conn)
if (SEQ_LT(already_sent, 0)) {
/* RFC 761, section 2.1. */
- trace("TCP: ACK sequence gap: ACK for %lu, sent: %lu",
+ trace("TCP: ACK sequence gap: ACK for %u, sent: %u",
conn->seq_ack_from_tap, conn->seq_to_tap);
conn->seq_to_tap = conn->seq_ack_from_tap;
already_sent = 0;
@@ -2589,7 +2589,7 @@ static void tcp_data_from_tap(struct ctx *c, struct tcp_conn *conn,
}
if (retr) {
- trace("TCP: fast re-transmit, ACK: %lu, previous sequence: %lu",
+ trace("TCP: fast re-transmit, ACK: %u, previous sequence: %u",
max_ack_seq, conn->seq_to_tap);
conn->seq_ack_from_tap = max_ack_seq;
conn->seq_to_tap = max_ack_seq;
@@ -2956,17 +2956,17 @@ static void tcp_timer_handler(struct ctx *c, union epoll_ref ref)
conn_flag(c, conn, ~ACK_TO_TAP_DUE);
} else if (conn->flags & ACK_FROM_TAP_DUE) {
if (!(conn->events & ESTABLISHED)) {
- debug("TCP: index %i, handshake timeout", conn - tc);
+ debug("TCP: index %li, handshake timeout", conn - tc);
tcp_rst(c, conn);
} else if (CONN_HAS(conn, SOCK_FIN_SENT | TAP_FIN_ACKED)) {
- debug("TCP: index %i, FIN timeout", conn - tc);
+ debug("TCP: index %li, FIN timeout", conn - tc);
tcp_rst(c, conn);
} else if (conn->retrans == TCP_MAX_RETRANS) {
- debug("TCP: index %i, maximum retransmissions exceeded",
+ debug("TCP: index %li, retransmissions count exceeded",
conn - tc);
tcp_rst(c, conn);
} else {
- debug("TCP: index %i, ACK timeout, retry", conn - tc);
+ debug("TCP: index %li, ACK timeout, retry", conn - tc);
conn->retrans++;
conn->seq_to_tap = conn->seq_ack_from_tap;
tcp_data_from_sock(c, conn);
@@ -2984,7 +2984,7 @@ static void tcp_timer_handler(struct ctx *c, union epoll_ref ref)
*/
timerfd_settime(conn->timer, 0, &new, &old);
if (old.it_value.tv_sec == ACT_TIMEOUT) {
- debug("TCP: index %i, activity timeout", conn - tc);
+ debug("TCP: index %li, activity timeout", conn - tc);
tcp_rst(c, conn);
}
}
diff --git a/tcp_splice.c b/tcp_splice.c
index 3f2ef2e..24a3b4b 100644
--- a/tcp_splice.c
+++ b/tcp_splice.c
@@ -173,14 +173,14 @@ static void conn_flag_do(const struct ctx *c, struct tcp_splice_conn *conn,
return;
conn->flags &= flag;
- debug("TCP (spliced): index %i: %s dropped", (conn) - tc,
+ debug("TCP (spliced): index %li: %s dropped", conn - tc,
tcp_splice_flag_str[fls(~flag)]);
} else {
if (conn->flags & flag)
return;
conn->flags |= flag;
- debug("TCP (spliced): index %i: %s", (conn) - tc,
+ debug("TCP (spliced): index %li: %s", conn - tc,
tcp_splice_flag_str[fls(flag)]);
}
@@ -253,14 +253,14 @@ static void conn_event_do(const struct ctx *c, struct tcp_splice_conn *conn,
return;
conn->events &= event;
- debug("TCP (spliced): index %i, ~%s", conn - tc,
+ debug("TCP (spliced): index %li, ~%s", conn - tc,
tcp_splice_event_str[fls(~event)]);
} else {
if (conn->events & event)
return;
conn->events |= event;
- debug("TCP (spliced): index %i, %s", conn - tc,
+ debug("TCP (spliced): index %li, %s", conn - tc,
tcp_splice_event_str[fls(event)]);
}
@@ -286,7 +286,7 @@ static void tcp_table_splice_compact(struct ctx *c,
struct tcp_splice_conn *move;
if ((hole - tc) == --c->tcp.splice_conn_count) {
- debug("TCP (spliced): index %i (max) removed", hole - tc);
+ debug("TCP (spliced): index %li (max) removed", hole - tc);
return;
}
@@ -300,7 +300,7 @@ static void tcp_table_splice_compact(struct ctx *c,
move->pipe_b_a[0] = move->pipe_b_a[1] = -1;
move->flags = move->events = 0;
- debug("TCP (spliced): index %i moved to %i", move - tc, hole - tc);
+ debug("TCP (spliced): index %li moved to %li", move - tc, hole - tc);
tcp_splice_epoll_ctl(c, hole);
if (tcp_splice_epoll_ctl(c, hole))
conn_flag(c, hole, CLOSING);
@@ -338,7 +338,7 @@ static void tcp_splice_destroy(struct ctx *c, struct tcp_splice_conn *conn)
conn->events = CLOSED;
conn->flags = 0;
- debug("TCP (spliced): index %i, CLOSED", conn - tc);
+ debug("TCP (spliced): index %li, CLOSED", conn - tc);
tcp_table_splice_compact(c, conn);
}