summaryrefslogtreecommitdiff
path: root/usr.bin/aucat/aucat.c
diff options
context:
space:
mode:
authorAlexandre Ratchov <ratchov@cvs.openbsd.org>2019-02-21 06:19:52 +0000
committerAlexandre Ratchov <ratchov@cvs.openbsd.org>2019-02-21 06:19:52 +0000
commit4b1048e02917d21e3a041c1c26de72b48d013567 (patch)
tree97be7a2119ef6d8a16130b6966c04a6cf7f78634 /usr.bin/aucat/aucat.c
parent19ea9ecc64a84b20440a0767ea235fd79d6d394b (diff)
Use reallocarray in place of malloc(a * b) to handle possible
overflow in multiplication of malloc argument.
Diffstat (limited to 'usr.bin/aucat/aucat.c')
-rw-r--r--usr.bin/aucat/aucat.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/usr.bin/aucat/aucat.c b/usr.bin/aucat/aucat.c
index 02579159584..e114a5ae85a 100644
--- a/usr.bin/aucat/aucat.c
+++ b/usr.bin/aucat/aucat.c
@@ -1166,10 +1166,14 @@ playrec(char *dev, int mode, int bufsz, char *port)
return 0;
if (pledge("stdio audio", NULL) == -1)
err(1, "pledge");
+
n = sio_nfds(dev_sh);
if (dev_mh)
n += mio_nfds(dev_mh);
- pfds = xmalloc(n * sizeof(struct pollfd));
+ pfds = reallocarray(NULL, n, sizeof(struct pollfd));
+ if (pfds == NULL)
+ err(1, "malloc");
+
for (s = slot_list; s != NULL; s = s->next)
slot_init(s);
if (dev_mh == NULL)