summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2008-03-24 18:03:54 +0000
committerMarc Espie <espie@cvs.openbsd.org>2008-03-24 18:03:54 +0000
commit6cae4b3b38c5e8ee985025a9633858c0871527e0 (patch)
tree47b1849351a997d444095c48d3df464bada7fea7 /usr.bin
parent378ab8314fdccb82083d2b67f20c23984295f9d4 (diff)
bye, bye recalloc. Bad interface for various reasons.
discussed with deraadt@ and otto@ and millert@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/make/job.c8
-rw-r--r--usr.bin/make/memory.c13
-rw-r--r--usr.bin/make/memory.h4
3 files changed, 17 insertions, 8 deletions
diff --git a/usr.bin/make/job.c b/usr.bin/make/job.c
index 2f9016f3646..f6afd59401d 100644
--- a/usr.bin/make/job.c
+++ b/usr.bin/make/job.c
@@ -1,5 +1,5 @@
/* $OpenPackages$ */
-/* $OpenBSD: job.c,v 1.112 2008/01/29 22:23:10 espie Exp $ */
+/* $OpenBSD: job.c,v 1.113 2008/03/24 18:03:53 espie Exp $ */
/* $NetBSD: job.c,v 1.16 1996/11/06 17:59:08 christos Exp $ */
/*
@@ -713,9 +713,11 @@ prepare_pipe(struct job_pipe *p, int *fd)
ofdn = howmany(largest_fd+1, NFDBITS);
if (fdn != ofdn) {
- output_mask = erecalloc(output_mask, fdn,
+ output_mask = emult_realloc(output_mask, fdn,
sizeof(fd_mask));
- actual_mask = erecalloc(actual_mask, fdn,
+ memset(((char *)output_mask) + ofdn * sizeof(fd_mask),
+ 0, (fdn-ofdn) * sizeof(fd_mask));
+ actual_mask = emult_realloc(actual_mask, fdn,
sizeof(fd_mask));
mask_size = fdn * sizeof(fd_mask);
}
diff --git a/usr.bin/make/memory.c b/usr.bin/make/memory.c
index 66a2ee0781f..9572f50b700 100644
--- a/usr.bin/make/memory.c
+++ b/usr.bin/make/memory.c
@@ -1,5 +1,5 @@
/* $OpenPackages$ */
-/* $OpenBSD: memory.c,v 1.5 2008/01/29 22:23:10 espie Exp $ */
+/* $OpenBSD: memory.c,v 1.6 2008/03/24 18:03:53 espie Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -105,9 +105,16 @@ ecalloc(size_t s1, size_t s2)
}
void *
-erecalloc(void *ptr, size_t s1, size_t s2)
+emult_realloc(void *ptr, size_t s1, size_t s2)
{
- if ((ptr = recalloc(ptr, s1, s2)) == NULL)
+ size_t size;
+
+ if (s1 && SIZE_MAX / s1 < s2) {
+ errno = ENOMEM;
+ enocmem(s1, s2);
+ }
+ size = s1 * s2;
+ if ((ptr = realloc(ptr, size)) == NULL)
enocmem(s1, s2);
return ptr;
}
diff --git a/usr.bin/make/memory.h b/usr.bin/make/memory.h
index 6339a969b43..ff8bfd9e784 100644
--- a/usr.bin/make/memory.h
+++ b/usr.bin/make/memory.h
@@ -2,7 +2,7 @@
#define MEMORY_H
/* $OpenPackages$ */
-/* $OpenBSD: memory.h,v 1.4 2008/01/29 22:23:10 espie Exp $ */
+/* $OpenBSD: memory.h,v 1.5 2008/03/24 18:03:53 espie Exp $ */
/*-
* Copyright (c) 1988, 1989, 1990, 1993
@@ -43,7 +43,7 @@ extern void *emalloc(size_t);
extern char *estrdup(const char *);
extern void *erealloc(void *, size_t);
extern void *ecalloc(size_t, size_t);
-extern void *erecalloc(void *, size_t, size_t);
+extern void *emult_realloc(void *, size_t, size_t);
extern int eunlink(const char *);
extern void esetenv(const char *, const char *);