Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bgpd, ospfd: fix some dicey pointer arith in snmp modules #14466

Merged
merged 2 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bgpd/bgp_snmp_bgp4.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ static struct bgp_path_info *bgp4PathAttrLookup(struct variable *v, oid name[],
/* Set OID offset for prefix. */
offset = name + v->namelen;
oid2in_addr(offset, IN_ADDR_SIZE, &addr->prefix);
offset += IN_ADDR_SIZE;
offset++;

/* Prefix length. */
addr->prefixlen = *offset;
Expand Down Expand Up @@ -497,7 +497,7 @@ static struct bgp_path_info *bgp4PathAttrLookup(struct variable *v, oid name[],

offset = name + v->namelen;
oid_copy_in_addr(offset, &rn_p->u.prefix4);
offset += IN_ADDR_SIZE;
offset++;
*offset = rn_p->prefixlen;
offset++;
oid_copy_in_addr(offset,
Expand Down
26 changes: 13 additions & 13 deletions ospfd/ospf_snmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -906,15 +906,15 @@ static struct ospf_lsa *ospfLsdbLookup(struct variable *v, oid *name,
area = ospf_area_lookup_by_area_id(ospf, *area_id);
if (!area)
return NULL;
offset += IN_ADDR_SIZE;
offset++;

/* Type. */
*type = *offset;
offset++;

/* LS ID. */
oid2in_addr(offset, IN_ADDR_SIZE, ls_id);
offset += IN_ADDR_SIZE;
offset++;

/* Router ID. */
oid2in_addr(offset, IN_ADDR_SIZE, router_id);
Expand Down Expand Up @@ -971,7 +971,7 @@ static struct ospf_lsa *ospfLsdbLookup(struct variable *v, oid *name,
}

/* Router ID. */
offset += IN_ADDR_SIZE;
offset++;
offsetlen -= IN_ADDR_SIZE;
len = offsetlen;

Expand All @@ -996,11 +996,11 @@ static struct ospf_lsa *ospfLsdbLookup(struct variable *v, oid *name,
/* Fill in value. */
offset = name + v->namelen;
oid_copy_in_addr(offset, area_id);
offset += IN_ADDR_SIZE;
offset++;
*offset = lsa->data->type;
offset++;
oid_copy_in_addr(offset, &lsa->data->id);
offset += IN_ADDR_SIZE;
offset++;
oid_copy_in_addr(offset,
&lsa->data->adv_router);

Expand Down Expand Up @@ -1106,7 +1106,7 @@ static struct ospf_area_range *ospfAreaRangeLookup(struct variable *v,
if (!area)
return NULL;

offset += IN_ADDR_SIZE;
offset++;

/* Lookup area range. */
oid2in_addr(offset, IN_ADDR_SIZE, range_net);
Expand Down Expand Up @@ -1135,7 +1135,7 @@ static struct ospf_area_range *ospfAreaRangeLookup(struct variable *v,
return NULL;

do {
offset += IN_ADDR_SIZE;
offset++;
offsetlen -= IN_ADDR_SIZE;
len = offsetlen;

Expand All @@ -1157,7 +1157,7 @@ static struct ospf_area_range *ospfAreaRangeLookup(struct variable *v,
/* Fill in value. */
offset = name + v->namelen;
oid_copy_in_addr(offset, area_id);
offset += IN_ADDR_SIZE;
offset++;
oid_copy_in_addr(offset, range_net);

return range;
Expand Down Expand Up @@ -1560,7 +1560,7 @@ static struct ospf_interface *ospfIfLookup(struct variable *v, oid *name,
*length = v->namelen + IN_ADDR_SIZE + 1;
offset = name + v->namelen;
oid_copy_in_addr(offset, ifaddr);
offset += IN_ADDR_SIZE;
offset++;
*offset = *ifindex;
return oi;
}
Expand Down Expand Up @@ -1704,7 +1704,7 @@ static struct ospf_interface *ospfIfMetricLookup(struct variable *v, oid *name,
*length = v->namelen + IN_ADDR_SIZE + 1 + 1;
offset = name + v->namelen;
oid_copy_in_addr(offset, ifaddr);
offset += IN_ADDR_SIZE;
offset++;
*offset = *ifindex;
offset++;
*offset = OSPF_SNMP_METRIC_VALUE;
Expand Down Expand Up @@ -2242,7 +2242,7 @@ static struct ospf_lsa *ospfExtLsdbLookup(struct variable *v, oid *name,

/* LS ID. */
oid2in_addr(offset, IN_ADDR_SIZE, ls_id);
offset += IN_ADDR_SIZE;
offset++;

/* Router ID. */
oid2in_addr(offset, IN_ADDR_SIZE, router_id);
Expand Down Expand Up @@ -2270,7 +2270,7 @@ static struct ospf_lsa *ospfExtLsdbLookup(struct variable *v, oid *name,

oid2in_addr(offset, len, ls_id);

offset += IN_ADDR_SIZE;
offset++;
offsetlen -= IN_ADDR_SIZE;

/* Router ID. */
Expand All @@ -2293,7 +2293,7 @@ static struct ospf_lsa *ospfExtLsdbLookup(struct variable *v, oid *name,
*offset = OSPF_AS_EXTERNAL_LSA;
offset++;
oid_copy_in_addr(offset, &lsa->data->id);
offset += IN_ADDR_SIZE;
offset++;
oid_copy_in_addr(offset, &lsa->data->adv_router);

return lsa;
Expand Down