summaryrefslogtreecommitdiff
path: root/sbin/atactl/atactl.c
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/atactl/atactl.c
parentbe524287dc216d876f995eddcaf32762c702c6e9 (diff)
use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg
Diffstat (limited to 'sbin/atactl/atactl.c')
-rw-r--r--sbin/atactl/atactl.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/sbin/atactl/atactl.c b/sbin/atactl/atactl.c
index 602b2f8f04a..6f82264ac63 100644
--- a/sbin/atactl/atactl.c
+++ b/sbin/atactl/atactl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: atactl.c,v 1.37 2006/10/02 19:30:19 jmc Exp $ */
+/* $OpenBSD: atactl.c,v 1.38 2007/09/02 15:19:23 deraadt Exp $ */
/* $NetBSD: atactl.c,v 1.4 1999/02/24 18:49:14 jwise Exp $ */
/*-
@@ -1455,8 +1455,8 @@ device_smart_readlog(int argc, char *argv[])
* the latest one.
*/
nsect = nerr / 5 + (nerr % 5 != 0 ? 1 : 0);
- if ((newbuf = (u_int8_t *)malloc(nsect * DEV_BSIZE)) == NULL)
- err(1, "malloc()");
+ if ((newbuf = (u_int8_t *)calloc(nsect, DEV_BSIZE)) == NULL)
+ err(1, "calloc()");
memset(&req, 0, sizeof(req));
req.flags = ATACMD_READ;
req.command = ATAPI_SMART;