capability: fix string comparison in cap_name_to_number
authorMark Marshall <mark.marshall@omicronenergy.com>
Fri, 18 Jan 2019 08:10:34 +0000 (09:10 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Thu, 14 Feb 2019 13:40:57 +0000 (14:40 +0100)
The result of strcasecmp was being used incorrectly.  This function
returns 0 if the strings match.

Signed-off-by: Mark Marshall <mark.marshall@omicronenergy.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
libbb/capability.c

index 6587dcbf7ce57b4131c905e321e7016d986cc05d..d0ae78b9157c1fd747550823e4a4035618f479fa 100644 (file)
@@ -67,7 +67,7 @@ unsigned FAST_FUNC cap_name_to_number(const char *cap)
                goto found;
        }
        for (i = 0; i < ARRAY_SIZE(capabilities); i++) {
-               if (strcasecmp(capabilities[i], cap) != 0)
+               if (strcasecmp(capabilities[i], cap) == 0)
                        goto found;
        }
        bb_error_msg_and_die("unknown capability '%s'", cap);