1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-10 06:47:55 -08:00

Use reallocarray in place of malloc(a * b) to handle possible

overflow in multiplication of malloc argument.
This commit is contained in:
ratchov 2019-02-21 06:19:51 +00:00
parent 218a2c1fee
commit 1dec06dfe5

View File

@ -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)