From f74777da0b51ef717e86eb898dbd99708f32d483 Mon Sep 17 00:00:00 2001 From: Frode Nordahl Date: Mon, 20 Jan 2025 13:43:06 +0000 Subject: [PATCH] route-table: Avoid potential NULL ptr dereference. The gcc static analyzer pointed out a potential NULL pointer dereference in route_table_parse(). While the probability is low, let's plug it. Fixes: 0b8da9ae1f38 ("route: support IPv6 and use IPv4-mapped addresses") Fixes: 71785737ded2 ("route-table: Split header and attribute parsing.") Acked-by: Eelco Chaudron Signed-off-by: Frode Nordahl Signed-off-by: Ilya Maximets --- lib/route-table.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/route-table.c b/lib/route-table.c index 8106dc93d..fbda4c41d 100644 --- a/lib/route-table.c +++ b/lib/route-table.c @@ -469,6 +469,10 @@ route_table_parse(struct ofpbuf *buf, void *change) nlmsg = ofpbuf_at(buf, 0, NLMSG_HDRLEN); rtm = ofpbuf_at(buf, NLMSG_HDRLEN, sizeof *rtm); + if (!nlmsg || !rtm) { + return 0; + } + return route_table_parse__(buf, NLMSG_HDRLEN + sizeof *rtm, nlmsg, rtm, NULL, change); }