summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2014-10-18 04:12:57 +0000
committerderaadt <deraadt@openbsd.org>2014-10-18 04:12:57 +0000
commit15c8733c8b53ef27242b46ccd0f0ca071b14244a (patch)
tree188d8627e64d4fe113bce325afda53d93bcd6e5a
parentreallocarray() -- a little tricky to review (diff)
downloadwireguard-openbsd-15c8733c8b53ef27242b46ccd0f0ca071b14244a.tar.xz
wireguard-openbsd-15c8733c8b53ef27242b46ccd0f0ca071b14244a.zip
Use reallocarray()
ok doug
-rw-r--r--usr.sbin/npppd/npppd/mppe.c8
-rw-r--r--usr.sbin/npppd/npppd/npppd_ctl.c9
2 files changed, 7 insertions, 10 deletions
diff --git a/usr.sbin/npppd/npppd/mppe.c b/usr.sbin/npppd/npppd/mppe.c
index 40eff5ef06a..e6903485d1c 100644
--- a/usr.sbin/npppd/npppd/mppe.c
+++ b/usr.sbin/npppd/npppd/mppe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mppe.c,v 1.11 2014/07/21 01:51:11 guenther Exp $ */
+/* $OpenBSD: mppe.c,v 1.12 2014/10/18 04:12:57 deraadt Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* $Id: mppe.c,v 1.11 2014/07/21 01:51:11 guenther Exp $ */
+/* $Id: mppe.c,v 1.12 2014/10/18 04:12:57 deraadt Exp $ */
/**@file
*
* The implementation of MPPE(Microsoft Point-To-Point Encryption Protocol)
@@ -632,8 +632,8 @@ mppe_rc4_init(mppe *_mppe, mppe_rc4_t *_this, int has_oldkey)
}
if (has_oldkey)
- _this->old_session_keys =
- malloc(MPPE_KEYLEN * MPPE_NOLDKEY);
+ _this->old_session_keys = reallocarray(NULL,
+ MPPE_KEYLEN, MPPE_NOLDKEY);
else
_this->old_session_keys = NULL;
diff --git a/usr.sbin/npppd/npppd/npppd_ctl.c b/usr.sbin/npppd/npppd/npppd_ctl.c
index 7ef66e11f05..c57f0c8bd8c 100644
--- a/usr.sbin/npppd/npppd/npppd_ctl.c
+++ b/usr.sbin/npppd/npppd/npppd_ctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: npppd_ctl.c,v 1.12 2014/05/30 05:06:00 yasuoka Exp $ */
+/* $OpenBSD: npppd_ctl.c,v 1.13 2014/10/18 04:12:57 deraadt Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
@@ -128,11 +128,8 @@ npppd_ctl_add_started_ppp_id(struct npppd_ctl *_this, u_int ppp_id)
return (-1);
if (_this->started_ppp_pos + 1 >= _this->started_ppp_siz) {
started_ppp_siz = _this->started_ppp_siz + 128;
- if (_this->started_ppp == NULL)
- started_ppp = malloc(sizeof(u_int) * started_ppp_siz);
- else
- started_ppp = realloc(_this->started_ppp,
- sizeof(u_int) * started_ppp_siz);
+ started_ppp = reallocarray(_this->started_ppp,
+ started_ppp_siz, sizeof(u_int));
if (started_ppp == NULL)
return (-1);
_this->started_ppp = started_ppp;