diff options
author | Peter Valchev <pvalchev@cvs.openbsd.org> | 2003-04-17 07:39:25 +0000 |
---|---|---|
committer | Peter Valchev <pvalchev@cvs.openbsd.org> | 2003-04-17 07:39:25 +0000 |
commit | 03e42a2bfdea4baf1488af4b883ef0914c4d2510 (patch) | |
tree | c6b1ac22a69d0ce4680e6a08352a4173c7ad8f07 /sbin/routed | |
parent | 0d824afc4fb7b73ef4ea5a3673b5807ecebe769d (diff) |
use asprintf; fix (remove) some incorrectly sized buffers in the process
help & ok millert, miod, deraadt, tedu
Diffstat (limited to 'sbin/routed')
-rw-r--r-- | sbin/routed/table.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/sbin/routed/table.c b/sbin/routed/table.c index 1f0075ea849..3c986543211 100644 --- a/sbin/routed/table.c +++ b/sbin/routed/table.c @@ -1,4 +1,4 @@ -/* $OpenBSD: table.c,v 1.10 2003/03/13 09:09:27 deraadt Exp $ */ +/* $OpenBSD: table.c,v 1.11 2003/04/17 07:39:24 pvalchev Exp $ */ /* * Copyright (c) 1983, 1988, 1993 @@ -1657,7 +1657,7 @@ rtswitch(struct rt_entry *rt, struct rt_spare *rts) { struct rt_spare swap; - char label[10]; + char *label; /* Do not change permanent routes */ @@ -1675,10 +1675,14 @@ rtswitch(struct rt_entry *rt, return; swap = rt->rt_spares[0]; - (void)snprintf(label, sizeof label, "Use #%d", (int)(rts - rt->rt_spares)); - rtchange(rt, rt->rt_state & ~(RS_NET_SYN | RS_RDISC), - rts->rts_gate, rts->rts_router, rts->rts_metric, - rts->rts_tag, rts->rts_ifp, rts->rts_time, label); + if (asprintf(&label, "Use #%d", (int)(rts - rt->rt_spares)) == -1) + msglog("asprintf: cannot allocate memory"); + else { + rtchange(rt, rt->rt_state & ~(RS_NET_SYN | RS_RDISC), + rts->rts_gate, rts->rts_router, rts->rts_metric, + rts->rts_tag, rts->rts_ifp, rts->rts_time, label); + free(label); + } *rts = swap; } |