ifdata doesn't support long device names

Bug #370557 reported by Alan Pope ๐Ÿบ๐Ÿง๐Ÿฑ ๐Ÿฆ„
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
moreutils (Debian)
Fix Released
Unknown
moreutils (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: moreutils

alan@hactar:~$ ifdata -sib wlan0
Invalid data read, check!
Error getting statistics for wlan0

alan@hactar:~$ cat /proc/net/dev
Inter-| Receive | Transmit
 face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
    lo: 51332 644 0 0 0 0 0 0 51332 644 0 0 0 0 0 0
  eth0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
wmaster0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 wlan0:91263412 82099 0 0 0 0 0 0 8292238 65428 0 0 0 0 0 0
vboxnet0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  pan0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

This is due to the check on the field length of the device not being long enough. wmaster0 is more than 6 chars.

*** moreutils/ifdata.c 2008-02-02 22:00:53.000000000 +0000
--- moreutils-0.34ubuntu2/ifdata.c 2009-05-01 19:58:38.000000000 +0100
***************
*** 246,252 ****

   do {
    int items = fscanf(fd,
! " %6[^:]:%llu %llu %llu %llu %llu %llu %llu %llu "
     "%llu %llu %llu %llu %llu %llu %llu %llu",
     name,
     &ifstat->in_bytes, &ifstat->in_packets,
--- 246,252 ----

   do {
    int items = fscanf(fd,
! " %20[^:]:%llu %llu %llu %llu %llu %llu %llu %llu "
     "%llu %llu %llu %llu %llu %llu %llu %llu",
     name,
     &ifstat->in_bytes, &ifstat->in_packets,

ProblemType: Bug
Architecture: i386
DistroRelease: Ubuntu 9.04
Package: moreutils 0.34
ProcEnviron:
 PATH=(custom, user)
 LANG=en_GB.UTF-8
 SHELL=/bin/bash
SourcePackage: moreutils
Uname: Linux 2.6.28-11-generic i686

Revision history for this message
Alan Pope ๐Ÿบ๐Ÿง๐Ÿฑ ๐Ÿฆ„ (popey) wrote :
Revision history for this message
Alan Pope ๐Ÿบ๐Ÿง๐Ÿฑ ๐Ÿฆ„ (popey) wrote :

Hope this patch works out ok.

Revision history for this message
Alan Pope ๐Ÿบ๐Ÿง๐Ÿฑ ๐Ÿฆ„ (popey) wrote :

Lets try that again :)

Revision history for this message
Alan Pope ๐Ÿบ๐Ÿง๐Ÿฑ ๐Ÿฆ„ (popey) wrote :

Ok, to expand on my brief description.

ifdata fails with "Invalid data read, check! Error getting statistics for wlan0" due to it looking for 17 items from /proc/net/dev/ on a line (the wlan0 line in my system). However it also carves up the line expecting the net device to be up to 6 characters in length (which typically they are with eth1, wlan0 as examples). However sometimes they are longer:-

alan@hactar:~/Development/moreutils/moreutils-0.34$ cat /proc/net/dev
Inter-| Receive | Transmit
 face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
    lo: 11860 170 0 0 0 0 0 0 11860 170 0 0 0 0 0 0
  eth0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
wmaster0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 wlan0: 4015561 7480 0 0 0 0 0 0 1157487 8080 0 0 0 0 0 0
vboxnet0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  pan0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Note vboxnet0 and wmaster0 are both longer than 6 characters. According to include/linux/device.h the net device name can be up to 20 characters in length. So the patch just accommodates larger device names.

Revision history for this message
James Westby (james-w) wrote :

Hi Alan,

I actually meant to provide more explanation in the changelog, not
the bug report :-)

Also, the Maintainer field has to be adjusted according to

  https://wiki.ubuntu.com/DebianMaintainerField

which can be done with "update-maintainer" in the ubuntu-dev-tools
package.

Attached is a patch with the suggested changes.

Did you manage to get submittodebian to work? Once the patch
is in the Debian BTS then I would be happy to upload this.

Thanks,

James

Revision history for this message
Alan Pope ๐Ÿบ๐Ÿง๐Ÿฑ ๐Ÿฆ„ (popey) wrote :

Have incorporated your change James and submitted to debian.

Changed in moreutils (Debian):
status: Unknown → Fix Committed
Changed in moreutils (Debian):
status: Fix Committed → Fix Released
Revision history for this message
James Westby (james-w) wrote :

Hey Popey,

This fix was just uploaded to Debian. As the package is unchanged in
Ubuntu and because of where we are in the release cycle the autosyncer
will update the package next time it is run. Once that's done we can
close the bug.

Thanks,

James

Revision history for this message
James Westby (james-w) wrote :

This has been synced now. Thanks popey.

James

Changed in moreutils (Ubuntu):
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.