From 6ebd04219f0d749c87a763e8afb578dfcd5223cc Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Sun, 2 Sep 2007 15:19:41 +0000 Subject: use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg --- usr.sbin/quot/quot.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'usr.sbin/quot/quot.c') diff --git a/usr.sbin/quot/quot.c b/usr.sbin/quot/quot.c index 3760aa19a82..2bfd2375208 100644 --- a/usr.sbin/quot/quot.c +++ b/usr.sbin/quot/quot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: quot.c,v 1.17 2007/07/04 17:14:45 millert Exp $ */ +/* $OpenBSD: quot.c,v 1.18 2007/09/02 15:19:40 deraadt Exp $ */ /* * Copyright (C) 1991, 1994 Wolfgang Solfrank. @@ -32,7 +32,7 @@ */ #ifndef lint -static char rcsid[] = "$Id: quot.c,v 1.17 2007/07/04 17:14:45 millert Exp $"; +static char rcsid[] = "$Id: quot.c,v 1.18 2007/09/02 15:19:40 deraadt Exp $"; #endif /* not lint */ #include @@ -437,7 +437,7 @@ douser(int fd, struct fs *super, char *name) else if (errno) err(1, "%s", name); } - if (!(usrs = (struct user *)malloc(nusers * sizeof(struct user)))) + if (!(usrs = (struct user *)calloc(nusers, sizeof(struct user)))) err(1, "allocate users"); memcpy(usrs, users, nusers * sizeof(struct user)); sortusers(usrs); -- cgit v1.2.3