Package: bwm Version: 1.1.0-8 Severity: normal Tags: patch Long device names are not cut off properly. I've got a device named "tun6to4_ppp0" for IPv6 which gives me 3 garbled characters and moves the tables two spaces to the right as shown here:
<----- snip -----> Bandwidth Monitor 1.1.0 Iface RX(KB/sec) TX(KB/sec) Total(KB/sec) dsl0 4.616 10.716 15.332 lo 0.106 0.106 0.212 eth0 59.919 316.439 376.358 eth1 0.000 0.000 0.000 teql0 0.000 0.000 0.000 sit0 0.000 0.000 0.000 ppp0 4.392 10.480 14.872 tun6to4_ppp·ëM 0.000 0.000 0.000 tun0 0.000 0.000 0.000 Total 69.033 337.741 406.774 Hit CTRL-C to end this madness. <----- snap -----> Cause for this error is the improper use of strncpy() which does not add an '\0' at the end of a string when characters are cut off. I've written two different patches to solve this problem. One patch aligns the device name to the left before cut-off, the other patch aligns the device name to the right. Please apply either one as you see fit. I think that the rightbound variant is the better one because it tries to keep the device names different as you can see in this example: original device name |leftbound |rightbound | ===========:---------|===========|===========| ppp0 : | ppp0| ppp0| ppp1 : | ppp1| ppp1| tun6to4_ppp0 |tun6to4_ppp|un6to4_ppp0| tun6to4_ppp1 |tun6to4_ppp|un6to4_ppp1| tun6to4_ppp2 |tun6to4_ppp|un6to4_ppp2| really_long_device |really_long|long_device| -- System Information: Debian Release: 3.1 APT prefers testing APT policy: (500, 'testing'), (50, 'unstable') Architecture: i386 (i686) Kernel: Linux 2.6.10 Locale: [EMAIL PROTECTED], [EMAIL PROTECTED] (charmap=ISO-8859-15) Versions of packages bwm depends on: ii libc6 2.3.2.ds1-20 GNU C Library: Shared libraries an -- no debconf information -- ....Christian.Garbs.....................................http://www.cgarbs.de o _______________ /\_ _| | _\__`[_______________| ] [ \, ][ ][
diff -Naru bwm-1.1.0.orig/bwm.c bwm-1.1.0/bwm.c --- bwm-1.1.0.orig/bwm.c 2005-02-11 17:51:23.000000000 +0100 +++ bwm-1.1.0/bwm.c 2005-02-11 17:53:26.000000000 +0100 @@ -126,6 +126,7 @@ buffer_pointer = buffer; buffer_pointer = strtok(buffer_pointer, " :"); strncpy(interface[inum].name, buffer_pointer, 11); + interface[inum].name[11]='\0'; field_number = 0;
diff -Naru bwm-1.1.0.orig/bwm.c bwm-1.1.0/bwm.c --- bwm-1.1.0.orig/bwm.c 2005-02-11 17:51:23.000000000 +0100 +++ bwm-1.1.0/bwm.c 2005-02-11 17:54:41.000000000 +0100 @@ -125,7 +125,10 @@ { buffer_pointer = buffer; buffer_pointer = strtok(buffer_pointer, " :"); - strncpy(interface[inum].name, buffer_pointer, 11); + if (strlen(buffer_pointer) > 11) { + buffer_pointer += strlen(buffer_pointer) - 11; + } + strncpy(interface[inum].name, buffer_pointer, 12); field_number = 0;
signature.asc
Description: Digital signature