summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Obser <florian@cvs.openbsd.org>2016-09-17 09:21:17 +0000
committerFlorian Obser <florian@cvs.openbsd.org>2016-09-17 09:21:17 +0000
commit1c6f0256acf2f9530533752951672ebebec3139e (patch)
treef9f44449edf5b368f75a5168b71bad8048ec640a
parent9266ad31f58ddfea50057d4e7a717829fade1ce1 (diff)
Normalize receive packet allocation.
-rw-r--r--sbin/ping/ping.c5
-rw-r--r--sbin/ping6/ping6.c4
2 files changed, 5 insertions, 4 deletions
diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c
index 765d7b943e5..873124175cc 100644
--- a/sbin/ping/ping.c
+++ b/sbin/ping/ping.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ping.c,v 1.188 2016/09/17 09:19:44 florian Exp $ */
+/* $OpenBSD: ping.c,v 1.189 2016/09/17 09:21:16 florian Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -471,8 +471,9 @@ main(int argc, char *argv[])
if (datalen >= sizeof(struct payload)) /* can we time transfer */
timing = 1;
packlen = datalen + MAXIPLEN + MAXICMPLEN;
- if (!(packet = malloc((size_t)packlen)))
+ if (!(packet = malloc(packlen)))
err(1, "malloc");
+
if (!(options & F_PINGFILLED))
for (i = ECHOTMLEN; i < datalen; ++i)
*datap++ = i;
diff --git a/sbin/ping6/ping6.c b/sbin/ping6/ping6.c
index 98049b572dc..adcc4e6c92e 100644
--- a/sbin/ping6/ping6.c
+++ b/sbin/ping6/ping6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ping6.c,v 1.201 2016/09/17 09:20:39 florian Exp $ */
+/* $OpenBSD: ping6.c,v 1.202 2016/09/17 09:21:16 florian Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -452,7 +452,7 @@ main(int argc, char *argv[])
packlen = datalen + IP6LEN + ECHOLEN + EXTRA;
if (!(packet = malloc(packlen)))
- err(1, "Unable to allocate packet");
+ err(1, "malloc");
if (!(options & F_PINGFILLED))
for (i = ECHOTMLEN; i < datalen; ++i)