Package: swapspace Version: 1.6-1 Severity: important Tags: patch
Installed the swapspace package but it failed to start, complaining of a parse error in /proc/meminfo. After examining the situation, I discovered that one of the entries in my /proc/meminfo had an embedded space in the entry name. The attached patch fixes the problem by modifying the sscanf call to look for "%[^:]: " instead of "%s " for the first field in each /proc/meminfo line. -- System Information: Debian Release: testing/unstable APT prefers testing APT policy: (500, 'testing') Architecture: i386 (i686) Shell: /bin/sh linked to /bin/bash Kernel: Linux 2.6.17-mm4 Locale: LANG=en_US, LC_CTYPE=en_US (charmap=ANSI_X3.4-1968) (ignored: LC_ALL set to C) Versions of packages swapspace depends on: ii libc6 2.3.6-15 GNU C Library: Shared libraries swapspace recommends no packages. -- no debconf information
diff -ur swapspace-1.6/src/memory.c swapspace-1.6-patched/src/memory.c --- swapspace-1.6/src/memory.c 2006-06-15 05:01:50.000000000 -0400 +++ swapspace-1.6-patched/src/memory.c 2006-07-08 23:32:27.000000000 -0400 @@ -115,7 +115,7 @@ char fact[20]; const int x = sscanf(localbuf, - "%s %lld %19s", + "%[^:]: %lld %19s", result->entry, &result->value, fact); @@ -212,31 +212,31 @@ switch (inf->entry[0]) { case 'B': - if (strcmp(inf->entry, "Buffers:")==0) st->Buffers = inf->value; + if (strcmp(inf->entry, "Buffers")==0) st->Buffers = inf->value; break; case 'C': - if (strcmp(inf->entry, "Cached:")==0) st->Cached = inf->value; + if (strcmp(inf->entry, "Cached")==0) st->Cached = inf->value; break; case 'D': - if (strcmp(inf->entry, "Dirty:")==0) st->Dirty = inf->value; + if (strcmp(inf->entry, "Dirty")==0) st->Dirty = inf->value; break; case 'M': if (strncmp(inf->entry,"Mem",3) == 0) { - if (strcmp(inf->entry+3, "Total:")==0) st->MemTotal = inf->value; - else if (strcmp(inf->entry+3, "Free:")==0) st->MemFree = inf->value; + if (strcmp(inf->entry+3, "Total")==0) st->MemTotal = inf->value; + else if (strcmp(inf->entry+3, "Free")==0) st->MemFree = inf->value; } break; case 'S': if (strncmp(inf->entry,"Swap",4) == 0) { - if (strcmp(inf->entry+4, "Total:")==0) st->SwapTotal = inf->value; - else if (strcmp(inf->entry+4, "Free:")==0) st->SwapFree = inf->value; - else if (strcmp(inf->entry+4, "Cached:")==0) st->SwapCached = inf->value; + if (strcmp(inf->entry+4, "Total")==0) st->SwapTotal = inf->value; + else if (strcmp(inf->entry+4, "Free")==0) st->SwapFree = inf->value; + else if (strcmp(inf->entry+4, "Cached")==0) st->SwapCached = inf->value; } break; case 'W': - if (strcmp(inf->entry,"Writeback:")==0) st->Writeback = inf->value; + if (strcmp(inf->entry,"Writeback")==0) st->Writeback = inf->value; break; } }