From a973d15ae89354daf0251491c755c2718a385e6f Mon Sep 17 00:00:00 2001 From: deraadt Date: Sun, 13 Jul 2014 23:24:47 +0000 Subject: [PATCH] use mallocarray() --- sys/crypto/crypto.c | 8 ++++---- sys/crypto/cryptosoft.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sys/crypto/crypto.c b/sys/crypto/crypto.c index 021fa1c1f72..f62752d278b 100644 --- a/sys/crypto/crypto.c +++ b/sys/crypto/crypto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crypto.c,v 1.64 2014/07/12 18:50:00 tedu Exp $ */ +/* $OpenBSD: crypto.c,v 1.65 2014/07/13 23:24:47 deraadt Exp $ */ /* * The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu) * @@ -220,7 +220,7 @@ crypto_get_driverid(u_int8_t flags) if (crypto_drivers_num == 0) { crypto_drivers_num = CRYPTO_DRIVERS_INITIAL; - crypto_drivers = malloc(crypto_drivers_num * + crypto_drivers = mallocarray(crypto_drivers_num, sizeof(struct cryptocap), M_CRYPTO_DATA, M_NOWAIT); if (crypto_drivers == NULL) { crypto_drivers_num = 0; @@ -250,8 +250,8 @@ crypto_get_driverid(u_int8_t flags) return -1; } - newdrv = malloc(2 * crypto_drivers_num * - sizeof(struct cryptocap), M_CRYPTO_DATA, M_NOWAIT); + newdrv = mallocarray(crypto_drivers_num, + 2 * sizeof(struct cryptocap), M_CRYPTO_DATA, M_NOWAIT); if (newdrv == NULL) { splx(s); return -1; diff --git a/sys/crypto/cryptosoft.c b/sys/crypto/cryptosoft.c index 81b8f273a46..8715bed9e4f 100644 --- a/sys/crypto/cryptosoft.c +++ b/sys/crypto/cryptosoft.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cryptosoft.c,v 1.70 2014/07/12 18:50:00 tedu Exp $ */ +/* $OpenBSD: cryptosoft.c,v 1.71 2014/07/13 23:24:47 deraadt Exp $ */ /* * The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu) @@ -759,7 +759,7 @@ swcr_newsession(u_int32_t *sid, struct cryptoini *cri) } else swcr_sesnum *= 2; - swd = malloc(swcr_sesnum * sizeof(struct swcr_data *), + swd = mallocarray(swcr_sesnum, sizeof(struct swcr_data *), M_CRYPTO_DATA, M_NOWAIT | M_ZERO); if (swd == NULL) { /* Reset session number */ -- 2.20.1