From effd2d8296ef94bc005b49771ad9e9df8eedf87e Mon Sep 17 00:00:00 2001 From: Hajimu UMEMOTO Date: Mon, 4 Dec 2000 13:38:59 +0000 Subject: [PATCH] test strdup() failures. from: Chris Faulhaber Obtained from: KAME --- sbin/ping6/ping6.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sbin/ping6/ping6.c b/sbin/ping6/ping6.c index f8535344722..3d529b64992 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