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>
This commit is contained in:
parent
264d68edcf
commit
2a3b8dad33
2 changed files with 24 additions and 12 deletions
4
tcp.c
4
tcp.c
|
@ -868,16 +868,20 @@ static void conn_flag_do(const struct ctx *c, struct tcp_conn *conn,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
conn->flags &= flag;
|
conn->flags &= flag;
|
||||||
|
if (fls(~flag) >= 0) {
|
||||||
debug("TCP: index %li: %s dropped", conn - tc,
|
debug("TCP: index %li: %s dropped", conn - tc,
|
||||||
tcp_flag_str[fls(~flag)]);
|
tcp_flag_str[fls(~flag)]);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (conn->flags & flag)
|
if (conn->flags & flag)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
conn->flags |= flag;
|
conn->flags |= flag;
|
||||||
|
if (fls(flag) >= 0) {
|
||||||
debug("TCP: index %li: %s", conn - tc,
|
debug("TCP: index %li: %s", conn - tc,
|
||||||
tcp_flag_str[fls(flag)]);
|
tcp_flag_str[fls(flag)]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (flag == STALLED || flag == ~STALLED)
|
if (flag == STALLED || flag == ~STALLED)
|
||||||
tcp_epoll_ctl(c, conn);
|
tcp_epoll_ctl(c, conn);
|
||||||
|
|
|
@ -170,16 +170,20 @@ static void conn_flag_do(const struct ctx *c, struct tcp_splice_conn *conn,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
conn->flags &= flag;
|
conn->flags &= flag;
|
||||||
|
if (fls(~flag) >= 0) {
|
||||||
debug("TCP (spliced): index %li: %s dropped", conn - tc,
|
debug("TCP (spliced): index %li: %s dropped", conn - tc,
|
||||||
tcp_splice_flag_str[fls(~flag)]);
|
tcp_splice_flag_str[fls(~flag)]);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (conn->flags & flag)
|
if (conn->flags & flag)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
conn->flags |= flag;
|
conn->flags |= flag;
|
||||||
|
if (fls(flag) >= 0) {
|
||||||
debug("TCP (spliced): index %li: %s", conn - tc,
|
debug("TCP (spliced): index %li: %s", conn - tc,
|
||||||
tcp_splice_flag_str[fls(flag)]);
|
tcp_splice_flag_str[fls(flag)]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (flag == CLOSING)
|
if (flag == CLOSING)
|
||||||
tcp_splice_epoll_ctl(c, conn);
|
tcp_splice_epoll_ctl(c, conn);
|
||||||
|
@ -250,16 +254,20 @@ static void conn_event_do(const struct ctx *c, struct tcp_splice_conn *conn,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
conn->events &= event;
|
conn->events &= event;
|
||||||
|
if (fls(~event) >= 0) {
|
||||||
debug("TCP (spliced): index %li, ~%s", conn - tc,
|
debug("TCP (spliced): index %li, ~%s", conn - tc,
|
||||||
tcp_splice_event_str[fls(~event)]);
|
tcp_splice_event_str[fls(~event)]);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (conn->events & event)
|
if (conn->events & event)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
conn->events |= event;
|
conn->events |= event;
|
||||||
|
if (fls(event) >= 0) {
|
||||||
debug("TCP (spliced): index %li, %s", conn - tc,
|
debug("TCP (spliced): index %li, %s", conn - tc,
|
||||||
tcp_splice_event_str[fls(event)]);
|
tcp_splice_event_str[fls(event)]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (tcp_splice_epoll_ctl(c, conn))
|
if (tcp_splice_epoll_ctl(c, conn))
|
||||||
conn_flag(c, conn, CLOSING);
|
conn_flag(c, conn, CLOSING);
|
||||||
|
|
Loading…
Reference in a new issue