__str2flags fix
I found a minor bug in __str2flags where empty strings or short strings will match all or many flags respectively. Basically the test needs to ensure the test string is the same length as the table entry before doing a strncasecmp to avoid doing just a prefix test.
This commit is contained in:
parent
100403a99a
commit
32057bc154
1 changed files with 2 additions and 1 deletions
|
@ -993,7 +993,8 @@ int __str2flags(const char *buf, const struct trans_tbl *tbl, size_t tbl_len)
|
|||
t = strchr(p, ',');
|
||||
len = t ? t - p : strlen(p);
|
||||
for (i = 0; i < tbl_len; i++)
|
||||
if (!strncasecmp(tbl[i].a, p, len))
|
||||
if (len == strlen(tbl[i].a) &&
|
||||
!strncasecmp(tbl[i].a, p, len))
|
||||
flags |= tbl[i].i;
|
||||
|
||||
if (!t)
|
||||
|
|
Loading…
Add table
Reference in a new issue