cli: fix in matching command line arguments
Ensure in matches() that a non-empty cmd is given, otherwise as currently nmcli general - matches to '-h' and is thus treated as nmcli general -h Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
@@ -38,8 +38,8 @@
|
||||
int
|
||||
matches (const char *cmd, const char *pattern)
|
||||
{
|
||||
int len = strlen (cmd);
|
||||
if (len > strlen (pattern))
|
||||
size_t len = strlen (cmd);
|
||||
if (!len || len > strlen (pattern))
|
||||
return -1;
|
||||
return memcmp (pattern, cmd, len);
|
||||
}
|
||||
|
Reference in New Issue
Block a user