watchfrr: fix SA warning

`valid_command` now causes static analyzer complaints since it no
longer assumes `optarg` is non-NULL. If this was the case then
`valid_command` would return `false` (or 0) because it would mean the
string is empty and doesn't contain the '%s' it expects.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
This commit is contained in:
Rafael Zalamena 2021-01-26 13:58:34 -03:00
parent b12bc77cd3
commit 53a78fc1d9
1 changed files with 3 additions and 0 deletions

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, '%');
}