summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancois Dumontet <francois.dumontet@6wind.com>2024-10-21 12:49:50 +0200
committerMergify <37929162+mergify[bot]@users.noreply.github.com>2024-10-29 12:12:51 +0000
commit2432b6481e3e004a26eb197f3dd6155f930a71d7 (patch)
tree3817bf18372559e9707d358d97293c6b2b6061c6
parentdbda55017ca2e02225d907b8780d42ee58b0af5c (diff)
bgpd: fix crash when polling bgp4v2PathAttrTable
we have (gdb) p *path->attr->aspath $1 = {refcnt = 3, segments = 0x0, json = 0x0, str = 0x55723d0b7470 "", str_len = 0, asnotation = ASNOTATION_PLAIN} It looks like this aspath is empty, resulting in a size 0 and NULL pointer for path->attr->aspath->segments which leads to the SIGSEGV fixe: return 0 when segments is null. Signed-off-by: Francois Dumontet <francois.dumontet@6wind.com> (cherry picked from commit ee2f1b85cf95fcbfd0a54dc15b911f525e96b163)
-rw-r--r--bgpd/bgp_snmp_bgp4v2.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/bgpd/bgp_snmp_bgp4v2.c b/bgpd/bgp_snmp_bgp4v2.c
index e8c3e6513d..5f36e29876 100644
--- a/bgpd/bgp_snmp_bgp4v2.c
+++ b/bgpd/bgp_snmp_bgp4v2.c
@@ -933,7 +933,9 @@ static uint8_t *bgp4v2PathAttrTable(struct variable *v, oid name[],
else
return SNMP_IPADDRESS(bgp_empty_addr);
case BGP4V2_NLRI_AS_PATH_CALC_LENGTH:
- return SNMP_INTEGER(path->attr->aspath->segments->length);
+ return SNMP_INTEGER((path->attr->aspath && path->attr->aspath->segments)
+ ? path->attr->aspath->segments->length
+ : 0);
case BGP4V2_NLRI_AS_PATH:
return aspath_snmp_pathseg(path->attr->aspath, var_len);
case BGP4V2_NLRI_PATH_ATTR_UNKNOWN: