summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlteo <lteo@openbsd.org>2014-01-10 04:02:15 +0000
committerlteo <lteo@openbsd.org>2014-01-10 04:02:15 +0000
commitaf9a18414bb92ef64a1ced7c24294d73ef21748d (patch)
tree6487ad8ac08445de5025705666817d952305281f
parentbe forceful with removing the SHA256 file (diff)
downloadwireguard-openbsd-af9a18414bb92ef64a1ced7c24294d73ef21748d.tar.xz
wireguard-openbsd-af9a18414bb92ef64a1ced7c24294d73ef21748d.zip
Check the return values of the strdup() calls.
OK deraadt@
-rw-r--r--usr.sbin/tcpdrop/tcpdrop.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/usr.sbin/tcpdrop/tcpdrop.c b/usr.sbin/tcpdrop/tcpdrop.c
index d69c715225e..8928eb131a2 100644
--- a/usr.sbin/tcpdrop/tcpdrop.c
+++ b/usr.sbin/tcpdrop/tcpdrop.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcpdrop.c,v 1.12 2013/10/24 02:55:50 deraadt Exp $ */
+/* $OpenBSD: tcpdrop.c,v 1.13 2014/01/10 04:02:15 lteo Exp $ */
/*
* Copyright (c) 2004 Markus Friedl <markus@openbsd.org>
@@ -54,6 +54,8 @@ main(int argc, char **argv)
if (argc == 3) {
laddr1 = addr1 = strdup(argv[1]);
+ if (!addr1)
+ err(1, "strdup");
port1 = strrchr(addr1, ':');
if (port1)
*port1++ = '\0';
@@ -61,6 +63,8 @@ main(int argc, char **argv)
goto fail;
faddr2 = addr2 = strdup(argv[2]);
+ if (!addr2)
+ err(1, "strdup");
port2 = strrchr(addr2, ':');
if (port2)
*port2++ = '\0';
@@ -84,11 +88,15 @@ fail:
if (addr1[0] == '[' && addr1[strlen(addr1) - 1] == ']') {
laddr1 = strdup(addr1);
+ if (!laddr1)
+ err(1, "strdup");
laddr1[strlen(laddr1) - 1] = '\0';
laddr1++;
}
if (addr2[0] == '[' && addr2[strlen(addr2) - 1] == ']') {
faddr2 = strdup(addr2);
+ if (!faddr2)
+ err(1, "strdup");
faddr2[strlen(faddr2) - 1] = '\0';
faddr2++;
}