Skip to content

Commit

Permalink
Revert "ospfd: fix some dicey pointer arith in snmp module"
Browse files Browse the repository at this point in the history
This reverts commit 438ef98.

The previous code was correct even if the coverity scanner was
complaining.

Fixes: #15680
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
  • Loading branch information
louis-6wind committed Apr 23, 2024
1 parent 166a82c commit c7895ba
Showing 1 changed file with 13 additions and 13 deletions.
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++;
offset += IN_ADDR_SIZE;

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

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

/* 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++;
offset += IN_ADDR_SIZE;
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++;
offset += IN_ADDR_SIZE;
*offset = lsa->data->type;
offset++;
oid_copy_in_addr(offset, &lsa->data->id);
offset++;
offset += IN_ADDR_SIZE;
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++;
offset += IN_ADDR_SIZE;

/* 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++;
offset += IN_ADDR_SIZE;
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++;
offset += IN_ADDR_SIZE;
oid_copy_in_addr(offset, range_net);

return range;
Expand Down Expand Up @@ -1559,7 +1559,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++;
offset += IN_ADDR_SIZE;
*offset = *ifindex;
return oi;
}
Expand Down Expand Up @@ -1703,7 +1703,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++;
offset += IN_ADDR_SIZE;
*offset = *ifindex;
offset++;
*offset = OSPF_SNMP_METRIC_VALUE;
Expand Down Expand Up @@ -2241,7 +2241,7 @@ static struct ospf_lsa *ospfExtLsdbLookup(struct variable *v, oid *name,

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

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

oid2in_addr(offset, len, ls_id);

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

/* Router ID. */
Expand All @@ -2292,7 +2292,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++;
offset += IN_ADDR_SIZE;
oid_copy_in_addr(offset, &lsa->data->adv_router);

return lsa;
Expand Down

0 comments on commit c7895ba

Please sign in to comment.