diff options
author | 2010-01-24 12:21:05 +0000 | |
---|---|---|
committer | 2010-01-24 12:21:05 +0000 | |
commit | e2e6975d28e5421610635dcc92cd567facc65941 (patch) | |
tree | 84a58d2641129415c6d86e369d8b4741380a9a0c | |
parent | use nitems here, no real change (diff) | |
download | wireguard-openbsd-e2e6975d28e5421610635dcc92cd567facc65941.tar.xz wireguard-openbsd-e2e6975d28e5421610635dcc92cd567facc65941.zip |
In orig_intra_lsa_rtr(), don't allocate and free a temporary buffer
which easily fits on the stack.
OK claudio@
-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 */ } |