Module Name: src Committed By: kamil Date: Mon Jun 11 17:45:51 UTC 2018
Modified Files: src/sbin/ifconfig: af_inet.c Log Message: 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> To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sbin/ifconfig/af_inet.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.