summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2001-05-15 22:03:04 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2001-05-15 22:03:04 +0000
commit2ade0d317857e411c22ad064504f9f54b2ae466f (patch)
tree925527b66b6b8814901d89f3c24708874e20992a /sbin
parent17f1765495123848817f7a8637cc49428227ebdb (diff)
do not permit emalloc/erealloc of 0 sized objects
Diffstat (limited to 'sbin')
-rw-r--r--sbin/fsck/fsutil.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/sbin/fsck/fsutil.c b/sbin/fsck/fsutil.c
index 06c77426c5a..dfcc4b1ea3b 100644
--- a/sbin/fsck/fsutil.c
+++ b/sbin/fsck/fsutil.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fsutil.c,v 1.2 1997/07/25 19:13:18 mickey Exp $ */
+/* $OpenBSD: fsutil.c,v 1.3 2001/05/15 22:03:03 deraadt Exp $ */
/* $NetBSD: fsutil.c,v 1.2 1996/10/03 20:06:31 christos Exp $ */
/*
@@ -291,7 +291,11 @@ void *
emalloc(s)
size_t s;
{
- void *p = malloc(s);
+ void *p;
+
+ if (s == 0)
+ err(1, "malloc failed");
+ p = malloc(s);
if (p == NULL)
err(1, "malloc failed");
return p;
@@ -303,6 +307,8 @@ erealloc(p, s)
void *p;
size_t s;
{
+ if (s == 0)
+ err(1, "realloc failed");
p = realloc(p, s);
if (p == NULL)
err(1, "realloc failed");