summaryrefslogtreecommitdiffstats
path: root/usr.sbin/rtadvd
diff options
context:
space:
mode:
authorhrs <hrs@FreeBSD.org>2011-06-07 12:00:29 +0000
committerhrs <hrs@FreeBSD.org>2011-06-07 12:00:29 +0000
commit9f4e3900380b3875aadd339dfbba069e8311d193 (patch)
tree5b4b651515563615f2a946f5d6ec3aa5eccd7d2d /usr.sbin/rtadvd
parent81c81d4337809e30229236fb5fa9590d18c541df (diff)
downloadFreeBSD-src-9f4e3900380b3875aadd339dfbba069e8311d193.zip
FreeBSD-src-9f4e3900380b3875aadd339dfbba069e8311d193.tar.gz
- Use ELM_MALLOC() for struct rainfo.
- Fix a missing back pointer assignment in struct prefix to struct rainfo when addr="" is specified. This caused SIGSEGV. - Insert a prefix element to a tail queue after setting parameters.
Diffstat (limited to 'usr.sbin/rtadvd')
-rw-r--r--usr.sbin/rtadvd/config.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/usr.sbin/rtadvd/config.c b/usr.sbin/rtadvd/config.c
index ff5d90f..1b48868 100644
--- a/usr.sbin/rtadvd/config.c
+++ b/usr.sbin/rtadvd/config.c
@@ -229,13 +229,7 @@ getconfig(int idx)
__func__, intface);
}
- rai = malloc(sizeof(*rai));
- if (rai == NULL) {
- syslog(LOG_INFO, "<%s> %s: can't allocate enough memory",
- __func__, intface);
- exit(1);
- }
- memset(rai, 0, sizeof(*rai));
+ ELM_MALLOC(rai, exit(1));
TAILQ_INIT(&rai->rai_prefix);
#ifdef ROUTEINFO
TAILQ_INIT(&rai->rai_route);
@@ -394,10 +388,7 @@ getconfig(int idx)
/* allocate memory to store prefix information */
ELM_MALLOC(pfx, exit(1));
-
- /* link into chain */
- TAILQ_INSERT_TAIL(&rai->rai_prefix, pfx, pfx_next);
- rai->rai_pfxs++;
+ pfx->pfx_rainfo = rai;
pfx->pfx_origin = PREFIX_FROM_CONFIG;
if (inet_pton(AF_INET6, addr, &pfx->pfx_prefix) != 1) {
@@ -481,6 +472,9 @@ getconfig(int idx)
pfx->pfx_pltimeexpire =
now.tv_sec + pfx->pfx_preflifetime;
}
+ /* link into chain */
+ TAILQ_INSERT_TAIL(&rai->rai_prefix, pfx, pfx_next);
+ rai->rai_pfxs++;
}
if (rai->rai_advifprefix && rai->rai_pfxs == 0)
get_prefix(rai);
OpenPOWER on IntegriCloud