From 77dd285b0401334ee7129e0271e74019309c7609 Mon Sep 17 00:00:00 2001 From: ume Date: Mon, 4 Dec 2000 13:38:59 +0000 Subject: test strdup() failures. from: Chris Faulhaber Obtained from: KAME --- sbin/ping6/ping6.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'sbin') diff --git a/sbin/ping6/ping6.c b/sbin/ping6/ping6.c index f853534..3d529b6 100644 --- a/sbin/ping6/ping6.c +++ b/sbin/ping6/ping6.c @@ -444,11 +444,13 @@ main(argc, argv) #ifdef IPSEC_POLICY_IPSEC case 'P': options |= F_POLICY; - if (!strncmp("in", optarg, 2)) - policy_in = strdup(optarg); - else if (!strncmp("out", optarg, 3)) - policy_out = strdup(optarg); - else + if (!strncmp("in", optarg, 2)) { + if ((policy_in = strdup(optarg)) == NULL) + errx(1, "strdup"); + } else if (!strncmp("out", optarg, 3)) { + if ((policy_out = strdup(optarg)) == NULL) + errx(1, "strdup"); + } else errx(1, "invalid security policy"); break; #else -- cgit v1.1