mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-13 17:40:04 +00:00
[bgpd] fix some leaks introduced in aspath rewrite.
2006-01-16 Paul Jakma <paul.jakma@sun.com> * bgp_aspath.c: (assegment_append_asns) XREALLOC can return NULL theoretically, take care not to lose the allocated data. (aspath_hash_alloc) aspath_dup already set the aspath string - fix leak. (aspath_parse) aspath_hash_alloc dupes the entire aspath, including segments, but we forgot to free the temporary assegment.
This commit is contained in:
parent
c1b9800a60
commit
02335429e8
@ -1,3 +1,13 @@
|
|||||||
|
2006-01-16 Paul Jakma <paul.jakma@sun.com>
|
||||||
|
|
||||||
|
* bgp_aspath.c: (assegment_append_asns) XREALLOC can return
|
||||||
|
NULL theoretically, take care not to lose the allocated data.
|
||||||
|
(aspath_hash_alloc) aspath_dup already set the aspath
|
||||||
|
string - fix leak.
|
||||||
|
(aspath_parse) aspath_hash_alloc dupes the entire aspath,
|
||||||
|
including segments, but we forgot to free the temporary
|
||||||
|
assegment.
|
||||||
|
|
||||||
2006-01-10 Juris Kalnins <juris@mt.lv>
|
2006-01-10 Juris Kalnins <juris@mt.lv>
|
||||||
|
|
||||||
* bgpd.h: (bgp_router_id_unset) ex-function, remove.
|
* bgpd.h: (bgp_router_id_unset) ex-function, remove.
|
||||||
|
@ -209,11 +209,14 @@ assegment_prepend_asns (struct assegment *seg, as_t asnum, int num)
|
|||||||
static struct assegment *
|
static struct assegment *
|
||||||
assegment_append_asns (struct assegment *seg, as_t *asnos, int num)
|
assegment_append_asns (struct assegment *seg, as_t *asnos, int num)
|
||||||
{
|
{
|
||||||
seg->as = XREALLOC (MTYPE_AS_SEG_DATA, seg->as,
|
as_t *newas;
|
||||||
|
|
||||||
|
newas = XREALLOC (MTYPE_AS_SEG_DATA, seg->as,
|
||||||
ASSEGMENT_DATA_SIZE (seg->length + num));
|
ASSEGMENT_DATA_SIZE (seg->length + num));
|
||||||
|
|
||||||
if (seg->as)
|
if (newas)
|
||||||
{
|
{
|
||||||
|
seg->as = newas;
|
||||||
memcpy (seg->as + seg->length, asnos, ASSEGMENT_DATA_SIZE(num));
|
memcpy (seg->as + seg->length, asnos, ASSEGMENT_DATA_SIZE(num));
|
||||||
seg->length += num;
|
seg->length += num;
|
||||||
return seg;
|
return seg;
|
||||||
@ -582,9 +585,6 @@ aspath_hash_alloc (void *arg)
|
|||||||
/* New aspath strucutre is needed. */
|
/* New aspath strucutre is needed. */
|
||||||
aspath = aspath_dup (arg);
|
aspath = aspath_dup (arg);
|
||||||
|
|
||||||
/* Make AS path string. */
|
|
||||||
aspath->str = aspath_make_str_count (aspath);
|
|
||||||
|
|
||||||
/* Malformed AS path value. */
|
/* Malformed AS path value. */
|
||||||
if (! aspath->str)
|
if (! aspath->str)
|
||||||
{
|
{
|
||||||
@ -670,6 +670,12 @@ aspath_parse (struct stream *s, size_t length)
|
|||||||
|
|
||||||
/* If already same aspath exist then return it. */
|
/* If already same aspath exist then return it. */
|
||||||
find = hash_get (ashash, &as, aspath_hash_alloc);
|
find = hash_get (ashash, &as, aspath_hash_alloc);
|
||||||
|
|
||||||
|
/* aspath_hash_alloc dupes segments too. that probably could be
|
||||||
|
* optimised out.
|
||||||
|
*/
|
||||||
|
assegment_free_all (as.segments);
|
||||||
|
|
||||||
if (! find)
|
if (! find)
|
||||||
return NULL;
|
return NULL;
|
||||||
find->refcnt++;
|
find->refcnt++;
|
||||||
|
Loading…
Reference in New Issue
Block a user