find_applet_by_name: loop index should be signed
authorRon Yorston <rmy@pobox.com>
Sun, 3 Apr 2016 20:29:35 +0000 (22:29 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sun, 3 Apr 2016 20:29:35 +0000 (22:29 +0200)
The loop

   for (j = ARRAY_SIZE(applet_nameofs)-1; j >= 0; j--) {

was intended to terminate when j goes negative, so j needs to be signed.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
libbb/appletlib.c

index d798a2eacc1e139888a8a9334e1e30dec02bd111..de654f64c8b34086ed0d7ea57dda3e3195c0650b 100644 (file)
@@ -141,7 +141,8 @@ void FAST_FUNC bb_show_usage(void)
 
 int FAST_FUNC find_applet_by_name(const char *name)
 {
-       unsigned i, j, max;
+       unsigned i, max;
+       int j;
        const char *p;
 
 /* The commented-out word-at-a-time code is ~40% faster, but +160 bytes.