diff options
author | 2007-09-02 15:19:07 +0000 | |
---|---|---|
committer | 2007-09-02 15:19:07 +0000 | |
commit | 1ed98fdf61d9dd29369f246109081408082ce54d (patch) | |
tree | ad7631e58c83830d1fc51cbadb9a2da53c1abfb7 /usr.bin/file/magic.c | |
parent | OpenCVS server init-support with OpenCVS and GNU cvs clients. (diff) | |
download | wireguard-openbsd-1ed98fdf61d9dd29369f246109081408082ce54d.tar.xz wireguard-openbsd-1ed98fdf61d9dd29369f246109081408082ce54d.zip |
use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg
Diffstat (limited to 'usr.bin/file/magic.c')
-rw-r--r-- | usr.bin/file/magic.c | 7 |
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); |