Merge pull request #7925 from opensourcerouting/watchfrr-netns

watchfrr: fix crash on missing optional argument
This commit is contained in:
Donald Sharp 2021-01-26 15:31:04 -05:00 committed by GitHub
commit b2fd215b21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1080,6 +1080,9 @@ static int valid_command(const char *cmd)
{
char *p;
if (cmd == NULL)
return 0;
return ((p = strchr(cmd, '%')) != NULL) && (*(p + 1) == 's')
&& !strchr(p + 1, '%');
}
@ -1414,7 +1417,7 @@ int main(int argc, char **argv)
} break;
case OPTION_NETNS:
netns_en = true;
if (strchr(optarg, '/')) {
if (optarg && strchr(optarg, '/')) {
fprintf(stderr,
"invalid network namespace name \"%s\" (may not contain slashes)\n",
optarg);