From: pcarana Date: Wed, 20 Mar 2019 23:22:24 +0000 (-0600) Subject: Add NULL check after strdup X-Git-Tag: v0.0.2~52^2~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ecc011df0ad4b3a4b02fdbf85443d12c3dc95dc7;p=thirdparty%2FFORT-validator.git Add NULL check after strdup --- diff --git a/src/configuration.c b/src/configuration.c index 31925932..cf9cd54e 100644 --- a/src/configuration.c +++ b/src/configuration.c @@ -191,8 +191,13 @@ handle_json(json_t *root) DEFAULT_VRPS_LOCATION, &vrps_location); if (error) return error; - /* TODO (review) check NULL */ + config.vrps_location = strdup(vrps_location); + if (config.vrps_location == NULL) { + err(errno, "'%s' couldn't be allocated.", + OPTNAME_VRPS_LOCATION); + return errno; + } /* * RFC 6810 and 8210: @@ -315,6 +320,11 @@ init_addrinfo(char const *hostname, char const *service) /* TODO (review) check NULL */ config.port = strdup(service); + if (config.port == NULL) { + err(errno, "'%s' couldn't be allocated.", OPTNAME_LISTEN_PORT); + return errno; + } + return 0; }