aboutgitcodebugslistschat
path: root/tcp.c
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2022-04-05 12:51:00 +0200
committerStefano Brivio <sbrivio@redhat.com>2022-04-07 11:44:35 +0200
commit2a3b8dad33d4921a210062101f92f5fe9e349ef0 (patch)
tree43f0774a7deba6c0146b7513084ee5b04d8ff2ef /tcp.c
parent264d68edcf797709837c6919f58a2170c4effddf (diff)
downloadpasst-2a3b8dad33d4921a210062101f92f5fe9e349ef0.tar
passt-2a3b8dad33d4921a210062101f92f5fe9e349ef0.tar.gz
passt-2a3b8dad33d4921a210062101f92f5fe9e349ef0.tar.bz2
passt-2a3b8dad33d4921a210062101f92f5fe9e349ef0.tar.lz
passt-2a3b8dad33d4921a210062101f92f5fe9e349ef0.tar.xz
passt-2a3b8dad33d4921a210062101f92f5fe9e349ef0.tar.zst
passt-2a3b8dad33d4921a210062101f92f5fe9e349ef0.zip
tcp, tcp_splice: False "Negative array index read" positives, CWE-129
A flag or event bit is always set by callers. Reported by Coverity. Signed-by-off: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'tcp.c')
-rw-r--r--tcp.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/tcp.c b/tcp.c
index 1820e19..13a108e 100644
--- a/tcp.c
+++ b/tcp.c
@@ -868,15 +868,19 @@ static void conn_flag_do(const struct ctx *c, struct tcp_conn *conn,
return;
conn->flags &= flag;
- debug("TCP: index %li: %s dropped", conn - tc,
- tcp_flag_str[fls(~flag)]);
+ if (fls(~flag) >= 0) {
+ 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 %li: %s", conn - tc,
- tcp_flag_str[fls(flag)]);
+ if (fls(flag) >= 0) {
+ debug("TCP: index %li: %s", conn - tc,
+ tcp_flag_str[fls(flag)]);
+ }
}
if (flag == STALLED || flag == ~STALLED)