NetBSD/sbin/ifconfig
kamil 5f51a87ea5 Correct Undefined Behavior in ifconfig(8)
Unportable left shift reported with MKSANITIZER=yes USE_SANITIZER=undefined:

# ifconfig
alc0: flags=0x8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        ec_capabilities=3<VLAN_MTU,VLAN_HWTAGGING>
        ec_enabled=0
        address: xx:xx:xx:xx:xx:xx
/public/src.git/sbin/ifconfig/af_inet.c:102:34: runtime error: left shift of 16777215 by 8 places cannot be represented in type 'int'
        inet 192.168.0.38/24 broadcast 192.168.0.255 flags 0x0
        inet6 xxxx::xxxx:xxxx:xxxx:xxx%alc0/64 flags 0x0 scopeid 0x1
lo0: flags=0x8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 33624
        inet 127.0.0.1/8 flags 0x0
        inet6 ::1/128 flags 0x20<NODAD>
        inet6 fe80::1%lo0/64 flags 0x0 scopeid 0x2

Change shifting left 1 to shifting 1U. This corrects the issue.

        if (cidr < 32) {                /* more than 1 bit in mask */
                /* check for non-contig netmask */
                if ((mask ^ (((1 << cidr) - 1) << (32 - cidr))) != 0) // <- here
                        return -1;      /* noncontig, no pfxlen */
        }

Solution suggested by <uwe>

Sponsored by <The NetBSD Foundation>
2018-06-11 17:45:50 +00:00
..
af_atalk.c use the new scopeid functions 2013-10-19 00:35:30 +00:00
af_inet6.c Modernise the output for the address to address/prefix instead 2016-10-01 15:10:58 +00:00
af_inet.c Correct Undefined Behavior in ifconfig(8) 2018-06-11 17:45:50 +00:00
af_inetany.c
af_inetany.h
af_link.c Rename link to link_pkw to avoid shadowing the link syscall. 2014-01-19 22:31:13 +00:00
agr.c
carp.c
env.c PR/50909: David Binderman: Optimize memset 2016-03-07 15:56:17 +00:00
env.h
ether.c
extern.h
ieee80211.c fix bugs in ssid printing 2016-09-22 18:22:51 +00:00
ifconfig_hostops.c
ifconfig_rumpops.c
ifconfig.8 New sentence, new line. 2017-02-16 13:51:08 +00:00
ifconfig.c -W seconds will wait for the detached flag to clear on addresses on 2016-01-07 11:32:21 +00:00
l2tp.c add l2tp(4) subcomands to ifconfig(8). 2017-02-16 08:28:03 +00:00
Makefile user librumpres 2017-10-10 19:30:06 +00:00
Makefile.common We don't need agr or l2tp when we are small. 2017-05-02 20:12:27 +00:00
media.c Don't bail if SIOGIFMEDIA doesn't return any media lists because we 2016-09-14 11:46:43 +00:00
media.h
parse.c print the next parser name instead of just the pointer in debugging. 2013-07-17 15:42:03 +00:00
parse.h
pfsync.c
prog_ops.h
tunnel.c use correct function 2013-10-19 15:59:15 +00:00
util.c use the new scopeid functions 2013-10-19 00:35:30 +00:00
util.h -W seconds will wait for the detached flag to clear on addresses on 2016-01-07 11:32:21 +00:00
vlan.c Add -vlanif to the help message of ifconfig 2014-09-15 06:46:04 +00:00