aboutgitcodebugslistschat
path: root/tcp.c
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2022-06-08 11:08:29 +0200
committerStefano Brivio <sbrivio@redhat.com>2022-06-08 11:08:29 +0200
commitdeda03bfc2fdcceb8a48ffa462d73d029e80e342 (patch)
tree2c8a5bcbf6bca33364d36564695d07f55f6a7a4f /tcp.c
parentfb59cfc9093b2c68d5fa65bb6eb4d4042dab0593 (diff)
downloadpasst-deda03bfc2fdcceb8a48ffa462d73d029e80e342.tar
passt-deda03bfc2fdcceb8a48ffa462d73d029e80e342.tar.gz
passt-deda03bfc2fdcceb8a48ffa462d73d029e80e342.tar.bz2
passt-deda03bfc2fdcceb8a48ffa462d73d029e80e342.tar.lz
passt-deda03bfc2fdcceb8a48ffa462d73d029e80e342.tar.xz
passt-deda03bfc2fdcceb8a48ffa462d73d029e80e342.tar.zst
passt-deda03bfc2fdcceb8a48ffa462d73d029e80e342.zip
tcp: Silence warning from gcc 11.3 with -Ofast
If the first packet_get() call doesn't assign len, the second one will also return NULL, but gcc doesn't see this. Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'tcp.c')
-rw-r--r--tcp.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/tcp.c b/tcp.c
index 53af3db..5b84110 100644
--- a/tcp.c
+++ b/tcp.c
@@ -2505,7 +2505,11 @@ static void tcp_data_from_tap(struct ctx *c, struct tcp_conn *conn,
char *data;
size_t off;
- packet_get(p, i, 0, 0, &len);
+ if (!packet_get(p, i, 0, 0, &len)) {
+ tcp_rst(c, conn);
+ return;
+ }
+
th = packet_get(p, i, 0, sizeof(*th), NULL);
if (!th) {
tcp_rst(c, conn);
@@ -2729,7 +2733,9 @@ int tcp_tap_handler(struct ctx *c, int af, const void *addr,
int ack_due = 0;
char *opts;
- packet_get(p, 0, 0, 0, &len);
+ if (!packet_get(p, 0, 0, 0, &len))
+ return 1;
+
th = packet_get(p, 0, 0, sizeof(*th), NULL);
if (!th)
return 1;