mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-08 05:28:07 +02:00
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:
parent
ccc912e870
commit
93131b1df2
1 changed files with 2 additions and 2 deletions
|
|
@ -38,8 +38,8 @@
|
||||||
int
|
int
|
||||||
matches (const char *cmd, const char *pattern)
|
matches (const char *cmd, const char *pattern)
|
||||||
{
|
{
|
||||||
int len = strlen (cmd);
|
size_t len = strlen (cmd);
|
||||||
if (len > strlen (pattern))
|
if (!len || len > strlen (pattern))
|
||||||
return -1;
|
return -1;
|
||||||
return memcmp (pattern, cmd, len);
|
return memcmp (pattern, cmd, len);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue