summaryrefslogtreecommitdiffstats
path: root/watchfrr
diff options
context:
space:
mode:
authorRafael Zalamena <rzalamena@opensourcerouting.org>2021-01-26 17:58:34 +0100
committerRafael Zalamena <rzalamena@opensourcerouting.org>2021-01-26 18:13:07 +0100
commit53a78fc1d9b900ae43333f755c9617a618989ae6 (patch)
treef0f8b290154cb601ead74dcf55581bf66e83a0d3 /watchfrr
parentwatchfrr: fix crash on missing optional argument (diff)
downloadfrr-53a78fc1d9b900ae43333f755c9617a618989ae6.tar.xz
frr-53a78fc1d9b900ae43333f755c9617a618989ae6.zip
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>
Diffstat (limited to 'watchfrr')
-rw-r--r--watchfrr/watchfrr.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/watchfrr/watchfrr.c b/watchfrr/watchfrr.c
index 12682fa35..441320b19 100644
--- a/watchfrr/watchfrr.c
+++ b/watchfrr/watchfrr.c
@@ -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, '%');
}