summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/ldomctl/util.c13
-rw-r--r--usr.sbin/ldomctl/util.h3
-rw-r--r--usr.sbin/ldomd/ds.c4
3 files changed, 16 insertions, 4 deletions
diff --git a/usr.sbin/ldomctl/util.c b/usr.sbin/ldomctl/util.c
index 89437f72ae3..eb160b32bd0 100644
--- a/usr.sbin/ldomctl/util.c
+++ b/usr.sbin/ldomctl/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.3 2012/11/24 10:42:46 kettenis Exp $ */
+/* $OpenBSD: util.c,v 1.4 2014/10/15 21:37:27 deraadt Exp $ */
/*
* Copyright (c) 2012 Mark Kettenis
@@ -47,6 +47,17 @@ xzalloc(size_t size)
return p;
}
+void *
+xreallocarray(void *o, size_t nmemb, size_t size)
+{
+ void *p;
+
+ p = reallocarray(o, nmemb, size);
+ if (p == NULL)
+ err(1, NULL);
+ return p;
+}
+
char *
xstrdup(const char *s)
{
diff --git a/usr.sbin/ldomctl/util.h b/usr.sbin/ldomctl/util.h
index 9f93388e76d..873de0a1011 100644
--- a/usr.sbin/ldomctl/util.h
+++ b/usr.sbin/ldomctl/util.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.h,v 1.3 2012/11/24 10:42:46 kettenis Exp $ */
+/* $OpenBSD: util.h,v 1.4 2014/10/15 21:37:27 deraadt Exp $ */
/*
* Copyright (c) 2012 Mark Kettenis
@@ -23,6 +23,7 @@ extern int debug;
void *xmalloc(size_t);
void *xzalloc(size_t);
+void *xreallocarray(void *, size_t, size_t);
char *xstrdup(const char *);
int xasprintf(char**, const char *, ...);
diff --git a/usr.sbin/ldomd/ds.c b/usr.sbin/ldomd/ds.c
index a3d4ecfaecf..2bb4ac752fe 100644
--- a/usr.sbin/ldomd/ds.c
+++ b/usr.sbin/ldomd/ds.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ds.c,v 1.4 2013/02/19 09:26:54 stsp Exp $ */
+/* $OpenBSD: ds.c,v 1.5 2014/10/15 21:37:27 deraadt Exp $ */
/*
* Copyright (c) 2012 Mark Kettenis
@@ -704,7 +704,7 @@ ds_conn_serve(void)
struct pollfd *pfd;
int nfds;
- pfd = xmalloc(num_ds_conns * sizeof(*pfd));
+ pfd = xreallocarray(NULL, num_ds_conns, sizeof(*pfd));
TAILQ_FOREACH(dc, &ds_conns, link) {
pfd[dc->id].fd = dc->fd;
pfd[dc->id].events = POLLIN;