diff options
author | Stefan Sperling <stsp@cvs.openbsd.org> | 2010-01-24 12:21:06 +0000 |
---|---|---|
committer | Stefan Sperling <stsp@cvs.openbsd.org> | 2010-01-24 12:21:06 +0000 |
commit | 65e8ac2759b5fd31e7dd136463c950f227c49695 (patch) | |
tree | af51a6626493e09380d9b315b7e09aed2eeaf82f /usr.sbin | |
parent | 6bb90517fca64948a396db7287b0dbe47d51b366 (diff) |
In orig_intra_lsa_rtr(), don't allocate and free a temporary buffer
which easily fits on the stack.
OK claudio@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ospf6d/rde.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/usr.sbin/ospf6d/rde.c b/usr.sbin/ospf6d/rde.c index 1585b739ef8..9d7e2d228c5 100644 --- a/usr.sbin/ospf6d/rde.c +++ b/usr.sbin/ospf6d/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.35 2009/12/22 19:32:36 claudio Exp $ */ +/* $OpenBSD: rde.c,v 1.36 2010/01/24 12:21:05 stsp Exp $ */ /* * Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org> @@ -1393,6 +1393,8 @@ link_lsa_from_full_nbr(struct lsa *lsa, struct iface *iface) struct lsa * orig_intra_lsa_rtr(struct area *area, struct vertex *old) { + char lsa_prefix_buf[sizeof(struct lsa_prefix) + + sizeof(struct in6_addr)]; struct lsa *lsa; struct lsa_prefix *lsa_prefix; struct in6_addr *prefix; @@ -1435,16 +1437,13 @@ orig_intra_lsa_rtr(struct area *area, struct vertex *old) continue; } - if ((lsa_prefix = calloc(sizeof(*lsa_prefix) - + sizeof(struct in6_addr), 1)) == NULL) - fatal("orig_intra_lsa_rtr"); + lsa_prefix = (struct lsa_prefix *)lsa_prefix_buf; TAILQ_FOREACH(ia, &iface->ifa_list, entry) { if (IN6_IS_ADDR_LINKLOCAL(&ia->addr)) continue; - bzero(lsa_prefix, sizeof(*lsa_prefix) - + sizeof(struct in6_addr)); + bzero(lsa_prefix_buf, sizeof(lsa_prefix_buf)); if (iface->type == IF_TYPE_POINTOMULTIPOINT || iface->state & IF_STA_LOOPBACK) { @@ -1464,8 +1463,6 @@ orig_intra_lsa_rtr(struct area *area, struct vertex *old) numprefix++; } - free(lsa_prefix); - /* TOD: Add prefixes of directly attached hosts, too */ /* TOD: Add prefixes for virtual links */ } |