Skip to content

Commit

Permalink
bgpd: fix coverity issue on aspath_filter_exclude_acl
Browse files Browse the repository at this point in the history
CID 1566378 (#1-4 of 4): Use after free (USE_AFTER_FREE)76.
use_after_free: Using freed pointer cur_seg.

now the prev_seg pointer is set with always existaing values.

Link: https://scan7.scan.coverity.com/reports.htm#v39104/p13747/fileInstanceId=146858993&defectInstanceId=18968273&mergedDefectId=1566378&fileStart=1376&fileEnd=1625
Fixes: 4685db4 (bgpd: add set as-path exclude acl-list command)

Signed-off-by: Francois Dumontet <[email protected]>
  • Loading branch information
fdumontet6WIND committed Sep 20, 2023
1 parent 0c9aabe commit c0b1105
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions bgpd/bgp_aspath.c
Original file line number Diff line number Diff line change
Expand Up @@ -1703,7 +1703,7 @@ struct aspath *aspath_filter_exclude_acl(struct aspath *source,
if (cur_seg == source->segments)
/* first segment */
source->segments = cur_seg->next;
else
else if (prev_seg)
prev_seg->next = cur_seg->next;
assegment_free(cur_seg);
}
Expand All @@ -1725,8 +1725,9 @@ struct aspath *aspath_filter_exclude_acl(struct aspath *source,
else if (prev_seg)
prev_seg->next = new_seg;
assegment_free(cur_seg);
}
prev_seg = cur_seg;
prev_seg = new_seg;
} else
prev_seg = cur_seg;
cur_seg = next_seg;
}

Expand Down

0 comments on commit c0b1105

Please sign in to comment.