summaryrefslogtreecommitdiff
path: root/sbin/ifconfig
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2007-09-02 15:19:41 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2007-09-02 15:19:41 +0000
commit6ebd04219f0d749c87a763e8afb578dfcd5223cc (patch)
treebb0f29e0a3791fff88551c93f5d4ba7113bdba43 /sbin/ifconfig
parentbe524287dc216d876f995eddcaf32762c702c6e9 (diff)
use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg
Diffstat (limited to 'sbin/ifconfig')
-rw-r--r--sbin/ifconfig/ifconfig.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c
index 44cd952f52a..6e7c2df97e4 100644
--- a/sbin/ifconfig/ifconfig.c
+++ b/sbin/ifconfig/ifconfig.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ifconfig.c,v 1.186 2007/08/25 20:05:30 henning Exp $ */
+/* $OpenBSD: ifconfig.c,v 1.187 2007/09/02 15:19:23 deraadt Exp $ */
/* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */
/*
@@ -896,7 +896,7 @@ list_cloners(void)
if (ioctl(s, SIOCIFGCLONERS, &ifcr) == -1)
err(1, "SIOCIFGCLONERS for count");
- buf = malloc(ifcr.ifcr_total * IFNAMSIZ);
+ buf = calloc(ifcr.ifcr_total, IFNAMSIZ);
if (buf == NULL)
err(1, "unable to allocate cloner name buffer");
@@ -2307,7 +2307,7 @@ status(int link, struct sockaddr_dl *sdl)
goto proto_status;
}
- media_list = (int *)malloc(ifmr.ifm_count * sizeof(int));
+ media_list = (int *)calloc(ifmr.ifm_count, sizeof(int));
if (media_list == NULL)
err(1, "malloc");
ifmr.ifm_ulist = media_list;