• Bug#265152: nagios-plugins: patch from bug #261151 introduces bus error

    From Sean Finney@1:229/2 to All on Thu Aug 12 01:20:04 2004
    From: [email protected]

    This is a multi-part MIME message sent by reportbug.

    Package: nagios-plugins
    Version: 1.3.1.0-8
    Severity: normal
    Tags: patch

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    i noticed that the latest version of check_swap from nagios-plugins
    bus errors on my ultra5. some debugging points me to this line:

    (gdb) where
    #0 0x7008a064 in _IO_vfscanf () from /lib/libc.so.6
    #1 0x70097edc in vsscanf () from /lib/libc.so.6
    #2 0x70092e54 in sscanf () from /lib/libc.so.6
    #3 0x00010eb4 in main (argc=-268437400, argv=0x129c0) at check_swap.c:89
    (gdb) frame 3
    #3 0x00010eb4 in main (argc=-268437400, argv=0x129c0) at check_swap.c:89
    89 else if (sscanf (input_buffer, "%*[S]%*[w]%*[a]%*[p]%[TotalFre]%*[:] %llu %*[k]%*[B]", str, &tmp)) {

    tmp, which is added in the patch from #261151, is declared as
    type long unsigned int. however, in the scanf function, it's
    scanned as long long unsigned int, which is 4 bytes larger...

    looking at the kernel source itself[1], it looks like these numbers
    are internally maintained as long unsigned, so i think scanning them
    as a %lu instead of %llu would solve this problem.

    the patch is so simple that it's almost not even worth attaching,
    but i've done so anyway, because i did put the Tag:...


    sean


    [1] http://lxr.linux.no/source/fs/proc/proc_misc.c?v=2.4.26
    or
    http://lxr.linux.no/source/fs/proc/proc_misc.c?v=2.6.5

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.2.4 (GNU/Linux)

    iD8DBQFBGqFhynjLPm522B0RAmpMAJsHUbfG30HiJ796HHPrIaHh5rKOdACfdZ2a PLeZXtDI81952h8wwlJhASc=
    =5GcH
    -----END PGP SIGNATURE-----

    --- 04_checkswap.dpatch.orig 2004-08-11 18:17:04.000000000 -0400
    +++ debian/patches/04_checkswap.dpatch 2004-08-11 18:24:40.000000000 -0400
    @@ -49,7 +49,7 @@
    asprintf (&status, "%s [%lu/%lu]", status, used, total);
    }
    }
    -+ else if (sscanf (input_buffer, "%*[S]%*[w]%*[a]%*[p]%[TotalFre]%*[:] %llu %*[k]%*[B]", str, &tmp)) {
    ++ else if (sscanf (input_buffer, "%*[S]%*[w]%*[a]%*[p]%[TotalFre]%*[:] %lu %*[k]%*[B]", str, &tmp)) {
    + if (strcmp ("Total", str) == 0) {
    + total_swap = tmp;
    }

    --- SoupGate-Win32 v1.05
    * Origin: you cannot sedate... all the things you hate (1:229/2)