]> granicus.if.org Git - procps-ng/commitdiff
sysctl: fix broken .conf suffix matching
authorMike Frysinger <vapier@gentoo.org>
Thu, 3 May 2012 05:07:58 +0000 (01:07 -0400)
committerSami Kerola <kerolasa@iki.fi>
Mon, 7 May 2012 07:00:38 +0000 (09:00 +0200)
There's an off-by-one error in the count (".conf" is 5 bytes, not 6),
and the logic is inverted for the strcmp return value -- we want to
skip the files when they *don't* end in .conf, not when they *do*.

Also fix the off-by-one len check.

Bug-Debian: http://bugs.debian.org/669128
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
sysctl.c

index 0c4a6309826f7d0dd24aba5d7e86e6a7c48a65fd..587e26d967ee94b0a58d995b53abb13b35c66c68 100644 (file)
--- a/sysctl.c
+++ b/sysctl.c
@@ -578,8 +578,8 @@ static int PreloadSystem(void)
                        if (!strcmp(de->d_name, ".")
                            || !strcmp(de->d_name, ".."))
                                continue;
-                       if (strlen(de->d_name) < 6
-                           || !strcmp(de->d_name + strlen(de->d_name) - 6, ".conf"))
+                       if (strlen(de->d_name) < 5
+                           || strcmp(de->d_name + strlen(de->d_name) - 5, ".conf"))
                                continue;
                        /* check if config already known */
                        for (i = 0; i < ncfgs; ++i) {