diff options
author | 2014-10-16 04:05:02 +0000 | |
---|---|---|
committer | 2014-10-16 04:05:02 +0000 | |
commit | f7222e84553f9b772773101ffd95b3f13ab9dab9 (patch) | |
tree | f4578e38efdabd65bad35df02aa32ecf711ce5f7 /usr.sbin/snmpd/kroute.c | |
parent | missing \n in printf; Daniel Wade (diff) | |
download | wireguard-openbsd-f7222e84553f9b772773101ffd95b3f13ab9dab9.tar.xz wireguard-openbsd-f7222e84553f9b772773101ffd95b3f13ab9dab9.zip |
use reallocarray(). Looked at a few times by doug, I am sure.
Diffstat (limited to 'usr.sbin/snmpd/kroute.c')
-rw-r--r-- | usr.sbin/snmpd/kroute.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/usr.sbin/snmpd/kroute.c b/usr.sbin/snmpd/kroute.c index 79090f155e0..a106445ad20 100644 --- a/usr.sbin/snmpd/kroute.c +++ b/usr.sbin/snmpd/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.28 2014/06/23 03:46:17 guenther Exp $ */ +/* $OpenBSD: kroute.c,v 1.29 2014/10/16 04:05:02 deraadt Exp $ */ /* * Copyright (c) 2007, 2008 Reyk Floeter <reyk@openbsd.org> @@ -227,14 +227,15 @@ ktable_new(u_int rtableid, u_int rdomid) /* resize index table if needed */ if (rtableid >= krt_size) { - oldsize = sizeof(struct ktable *) * krt_size; - newsize = sizeof(struct ktable *) * (rtableid + 1); - if ((xkrt = realloc(krt, newsize)) == NULL) { + if ((xkrt = reallocarray(krt, rtableid + 1, + sizeof(struct ktable *))) == NULL) { log_warn("%s: realloc", __func__); return (-1); } krt = xkrt; + oldsize = krt_size * sizeof(struct ktable *); krt_size = rtableid + 1; + newsize = krt_size * sizeof(struct ktable *); bzero((char *)krt + oldsize, newsize - oldsize); } |