summaryrefslogtreecommitdiffstats
path: root/usr.sbin/user
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2014-12-01 23:08:23 +0000
committerderaadt <deraadt@openbsd.org>2014-12-01 23:08:23 +0000
commit7f5296e572266be739e5274bb75073b539cda994 (patch)
tree9ef6692f0ee3d17a5eb4cfb7ccc4581206057879 /usr.sbin/user
parentmemcpy abort found an overlap. from dsp at 2f30. ok deraadt (diff)
downloadwireguard-openbsd-7f5296e572266be739e5274bb75073b539cda994.tar.xz
wireguard-openbsd-7f5296e572266be739e5274bb75073b539cda994.zip
use reallocarray() deep inside an macro ugly as sin
Diffstat (limited to 'usr.sbin/user')
-rw-r--r--usr.sbin/user/defs.h14
1 files changed, 9 insertions, 5 deletions
diff --git a/usr.sbin/user/defs.h b/usr.sbin/user/defs.h
index 4bf2eeada8e..2891fdda929 100644
--- a/usr.sbin/user/defs.h
+++ b/usr.sbin/user/defs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: defs.h,v 1.4 2004/04/19 17:48:31 millert Exp $ */
+/* $OpenBSD: defs.h,v 1.5 2014/12/01 23:08:23 deraadt Exp $ */
/* $NetBSD: defs.h,v 1.5 1999/12/24 09:08:49 agc Exp $ */
/*
@@ -35,15 +35,19 @@
#define DEFS_H_
#define NEWARRAY(type,ptr,size,action) do { \
- if ((ptr = (type *) calloc(size, sizeof(type))) == (type *) NULL) { \
- warn("can't allocate %ld bytes", (long)(size * sizeof(type))); \
+ if ((ptr = (type *) calloc((size), \
+ sizeof(type))) == (type *) NULL) { \
+ warn("can't allocate %ld bytes", \
+ (long)((size) * sizeof(type))); \
action; \
} \
} while( /* CONSTCOND */ 0)
#define RENEW(type,ptr,size,action) do { \
- if ((ptr = (type *) realloc(ptr, sizeof(type) * size)) == (type *) NULL) { \
- warn("can't realloc %ld bytes", (long)(size * sizeof(type))); \
+ if ((ptr = (type *) reallocarray(ptr, \
+ (size), sizeof(type))) == (type *) NULL) { \
+ warn("can't realloc %ld bytes", \
+ (long)((size) * sizeof(type))); \
action; \
} \
} while( /* CONSTCOND */ 0)