summaryrefslogtreecommitdiff
path: root/usr.bin/file
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 /usr.bin/file
parentbe524287dc216d876f995eddcaf32762c702c6e9 (diff)
use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg
Diffstat (limited to 'usr.bin/file')
-rw-r--r--usr.bin/file/magic.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/usr.bin/file/magic.c b/usr.bin/file/magic.c
index f2fd3bb179e..6640ed5cad4 100644
--- a/usr.bin/file/magic.c
+++ b/usr.bin/file/magic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: magic.c,v 1.3 2007/07/09 16:39:48 dim Exp $ */
+/* $OpenBSD: magic.c,v 1.4 2007/09/02 15:19:32 deraadt Exp $ */
/*
* Copyright (c) Christos Zoulas 2003.
* All Rights Reserved.
@@ -66,7 +66,7 @@
#include "patchlevel.h"
#ifndef lint
-FILE_RCSID("@(#)$Id: magic.c,v 1.3 2007/07/09 16:39:48 dim Exp $")
+FILE_RCSID("@(#)$Id: magic.c,v 1.4 2007/09/02 15:19:32 deraadt Exp $")
#endif /* lint */
#ifdef __EMX__
@@ -104,7 +104,8 @@ magic_open(int flags)
free(ms);
return NULL;
}
- ms->c.off = malloc((ms->c.len = 10) * sizeof(*ms->c.off));
+ ms->c.len = 10;
+ ms->c.off = calloc(ms->c.len, sizeof(*ms->c.off));
if (ms->c.off == NULL) {
free(ms->o.pbuf);
free(ms->o.buf);