From: lteo Date: Fri, 10 Jan 2014 04:02:15 +0000 (+0000) Subject: Check the return values of the strdup() calls. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=af9a18414bb92ef64a1ced7c24294d73ef21748d;p=openbsd Check the return values of the strdup() calls. OK deraadt@ --- 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 @@ -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++; }