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:
Thomas Haller
2013-11-11 14:43:50 +01:00
parent ccc912e870
commit 93131b1df2

View File

@@ -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);
}