[Bug 210380] [patch] fix net/nload interface name fetching

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Sun Jun 19 00:27:40 UTC 2016


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=210380

            Bug ID: 210380
           Summary: [patch] fix net/nload interface name fetching
           Product: Ports & Packages
           Version: Latest
          Hardware: Any
                OS: Any
            Status: New
          Keywords: patch
          Severity: Affects Many People
          Priority: ---
         Component: Individual Port(s)
          Assignee: ehaupt at FreeBSD.org
          Reporter: allanjude at FreeBSD.org
          Keywords: patch
          Assignee: ehaupt at FreeBSD.org
             Flags: maintainer-feedback?(ehaupt at FreeBSD.org)

Created attachment 171560
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=171560&action=edit
patch for net/nload

net/nload gets the network interface device names via struct sockaddr_dl

struct sockaddr_dl {
        u_char  sdl_len;        /* Total length of sockaddr */
        u_char  sdl_family;     /* AF_LINK */
        u_short sdl_index;      /* if != 0, system given index for interface */
        u_char  sdl_type;       /* interface type */
        u_char  sdl_nlen;       /* interface name length, no trailing 0 reqd.
*/
        u_char  sdl_alen;       /* link level address length */
        u_char  sdl_slen;       /* link layer selector length */
        char    sdl_data[46];   /* minimum work area, can be larger;
                                   contains both if name and ll address */
};


The name is stored in sdl_data, but is no longer null terminated. The first
sdl_nlen bytes are the device name, the sdl_alen bytes after that are the link
level address (MAC address), etc.

This small patch makes nload read only the first sdl_alen bytes as the device
name, instead of reading binary data as a string until it finds a null byte.

This happens to often work if the first byte of the mac address is 0.

before:
Device alc0~P+49▒d (1/11):
Device em0h^EÊ^W·o (2/11):

after:
Device alc0 (1/11):
Device em0 (2/11):

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-ports-bugs mailing list