summaryrefslogtreecommitdiffstats
path: root/lib/utils.c
diff options
context:
space:
mode:
authorJustin Mayfield <jmayfield@cradlepoint.com>2012-05-10 03:08:30 (GMT)
committerThomas Graf <tgraf@redhat.com>2012-05-10 07:12:18 (GMT)
commit32057bc15469e6f012841605daa38766497fa196 (patch)
tree3325e2e13954da66b742d2a2025de7c78e4e5511 /lib/utils.c
parent100403a99a1437459cf60173dd0f51859ae7d5fe (diff)
downloadlibnl-32057bc15469e6f012841605daa38766497fa196.zip
libnl-32057bc15469e6f012841605daa38766497fa196.tar.gz
libnl-32057bc15469e6f012841605daa38766497fa196.tar.bz2
__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.
Diffstat (limited to 'lib/utils.c')
-rw-r--r--lib/utils.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/utils.c b/lib/utils.c
index 0ec7626..83d424f 100644
--- a/lib/utils.c
+++ b/lib/utils.c
@@ -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)