ospfd: fix some dicey pointer arith in snmp module

Coverity reports some uses of 'oid *' as if they were 'char *';
try to correct that.

Signed-off-by: Mark Stapp <mjs@labn.net>
This commit is contained in:
Mark Stapp 2023-09-21 10:46:02 -04:00
parent 4d64badc5b
commit 438ef98701

View file

@ -906,7 +906,7 @@ static struct ospf_lsa *ospfLsdbLookup(struct variable *v, oid *name,
area = ospf_area_lookup_by_area_id(ospf, *area_id); area = ospf_area_lookup_by_area_id(ospf, *area_id);
if (!area) if (!area)
return NULL; return NULL;
offset += IN_ADDR_SIZE; offset++;
/* Type. */ /* Type. */
*type = *offset; *type = *offset;
@ -914,7 +914,7 @@ static struct ospf_lsa *ospfLsdbLookup(struct variable *v, oid *name,
/* LS ID. */ /* LS ID. */
oid2in_addr(offset, IN_ADDR_SIZE, ls_id); oid2in_addr(offset, IN_ADDR_SIZE, ls_id);
offset += IN_ADDR_SIZE; offset++;
/* Router ID. */ /* Router ID. */
oid2in_addr(offset, IN_ADDR_SIZE, router_id); oid2in_addr(offset, IN_ADDR_SIZE, router_id);
@ -971,7 +971,7 @@ static struct ospf_lsa *ospfLsdbLookup(struct variable *v, oid *name,
} }
/* Router ID. */ /* Router ID. */
offset += IN_ADDR_SIZE; offset++;
offsetlen -= IN_ADDR_SIZE; offsetlen -= IN_ADDR_SIZE;
len = offsetlen; len = offsetlen;
@ -996,11 +996,11 @@ static struct ospf_lsa *ospfLsdbLookup(struct variable *v, oid *name,
/* Fill in value. */ /* Fill in value. */
offset = name + v->namelen; offset = name + v->namelen;
oid_copy_in_addr(offset, area_id); oid_copy_in_addr(offset, area_id);
offset += IN_ADDR_SIZE; offset++;
*offset = lsa->data->type; *offset = lsa->data->type;
offset++; offset++;
oid_copy_in_addr(offset, &lsa->data->id); oid_copy_in_addr(offset, &lsa->data->id);
offset += IN_ADDR_SIZE; offset++;
oid_copy_in_addr(offset, oid_copy_in_addr(offset,
&lsa->data->adv_router); &lsa->data->adv_router);
@ -1106,7 +1106,7 @@ static struct ospf_area_range *ospfAreaRangeLookup(struct variable *v,
if (!area) if (!area)
return NULL; return NULL;
offset += IN_ADDR_SIZE; offset++;
/* Lookup area range. */ /* Lookup area range. */
oid2in_addr(offset, IN_ADDR_SIZE, range_net); oid2in_addr(offset, IN_ADDR_SIZE, range_net);
@ -1135,7 +1135,7 @@ static struct ospf_area_range *ospfAreaRangeLookup(struct variable *v,
return NULL; return NULL;
do { do {
offset += IN_ADDR_SIZE; offset++;
offsetlen -= IN_ADDR_SIZE; offsetlen -= IN_ADDR_SIZE;
len = offsetlen; len = offsetlen;
@ -1157,7 +1157,7 @@ static struct ospf_area_range *ospfAreaRangeLookup(struct variable *v,
/* Fill in value. */ /* Fill in value. */
offset = name + v->namelen; offset = name + v->namelen;
oid_copy_in_addr(offset, area_id); oid_copy_in_addr(offset, area_id);
offset += IN_ADDR_SIZE; offset++;
oid_copy_in_addr(offset, range_net); oid_copy_in_addr(offset, range_net);
return range; return range;
@ -1560,7 +1560,7 @@ static struct ospf_interface *ospfIfLookup(struct variable *v, oid *name,
*length = v->namelen + IN_ADDR_SIZE + 1; *length = v->namelen + IN_ADDR_SIZE + 1;
offset = name + v->namelen; offset = name + v->namelen;
oid_copy_in_addr(offset, ifaddr); oid_copy_in_addr(offset, ifaddr);
offset += IN_ADDR_SIZE; offset++;
*offset = *ifindex; *offset = *ifindex;
return oi; return oi;
} }
@ -1704,7 +1704,7 @@ static struct ospf_interface *ospfIfMetricLookup(struct variable *v, oid *name,
*length = v->namelen + IN_ADDR_SIZE + 1 + 1; *length = v->namelen + IN_ADDR_SIZE + 1 + 1;
offset = name + v->namelen; offset = name + v->namelen;
oid_copy_in_addr(offset, ifaddr); oid_copy_in_addr(offset, ifaddr);
offset += IN_ADDR_SIZE; offset++;
*offset = *ifindex; *offset = *ifindex;
offset++; offset++;
*offset = OSPF_SNMP_METRIC_VALUE; *offset = OSPF_SNMP_METRIC_VALUE;
@ -2242,7 +2242,7 @@ static struct ospf_lsa *ospfExtLsdbLookup(struct variable *v, oid *name,
/* LS ID. */ /* LS ID. */
oid2in_addr(offset, IN_ADDR_SIZE, ls_id); oid2in_addr(offset, IN_ADDR_SIZE, ls_id);
offset += IN_ADDR_SIZE; offset++;
/* Router ID. */ /* Router ID. */
oid2in_addr(offset, IN_ADDR_SIZE, router_id); oid2in_addr(offset, IN_ADDR_SIZE, router_id);
@ -2270,7 +2270,7 @@ static struct ospf_lsa *ospfExtLsdbLookup(struct variable *v, oid *name,
oid2in_addr(offset, len, ls_id); oid2in_addr(offset, len, ls_id);
offset += IN_ADDR_SIZE; offset++;
offsetlen -= IN_ADDR_SIZE; offsetlen -= IN_ADDR_SIZE;
/* Router ID. */ /* Router ID. */
@ -2293,7 +2293,7 @@ static struct ospf_lsa *ospfExtLsdbLookup(struct variable *v, oid *name,
*offset = OSPF_AS_EXTERNAL_LSA; *offset = OSPF_AS_EXTERNAL_LSA;
offset++; offset++;
oid_copy_in_addr(offset, &lsa->data->id); oid_copy_in_addr(offset, &lsa->data->id);
offset += IN_ADDR_SIZE; offset++;
oid_copy_in_addr(offset, &lsa->data->adv_router); oid_copy_in_addr(offset, &lsa->data->adv_router);
return lsa; return lsa;