>Synopsis: The second argument of ether_ntohost() should be "const struct >ether_addr *" >Category: <PR category (one line)> >Environment: System : OpenBSD 5.9 Details : OpenBSD 5.9 (GENERIC.MP) #1888: Fri Feb 26 01:20:19 MST 2016 dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
Architecture: OpenBSD.amd64 Machine : amd64 >Description: The second argument to ether_ntohost() is declared as "struct ether_addr *"; however, it doesn't modify the second argument, so it should be declared as "const struct ether_addr *" to avoid warnings if a const pointer is passed to it. In the other BSDs, OS X, and Solaris, it's a const pointer. >How-To-Repeat: Compile a program that passes a const pointer as the second argument with "-Wcast-qual". >Fix: Apply the following patch (which also cleans up the man page to claim only that the functions that actually use a static buffer do so). Index: lib/libc/net/ethers.3 =================================================================== RCS file: /cvs/src/lib/libc/net/ethers.3,v retrieving revision 1.24 diff -u -r1.24 ethers.3 --- lib/libc/net/ethers.3 10 Nov 2015 23:48:18 -0000 1.24 +++ lib/libc/net/ethers.3 8 Aug 2016 01:28:39 -0000 @@ -23,7 +23,7 @@ .Ft struct ether_addr * .Fn ether_aton "const char *s" .Ft int -.Fn ether_ntohost "char *hostname" "struct ether_addr *e" +.Fn ether_ntohost "char *hostname" "const struct ether_addr *e" .Ft int .Fn ether_hostton "const char *hostname" "struct ether_addr *e" .Ft int @@ -119,6 +119,10 @@ functions were adopted from SunOS and appeared in .Nx 0.9b . .Sh BUGS -The data space used by these functions is static; if future use +The data space used by +.Fn ether_ntoa +and +.Fn ether_aton +is static; if future use requires the data, it should be copied before any subsequent calls to these functions overwrite it. Index: lib/libc/net/ethers.c =================================================================== RCS file: /cvs/src/lib/libc/net/ethers.c,v retrieving revision 1.24 diff -u -r1.24 ethers.c --- lib/libc/net/ethers.c 14 Sep 2015 11:01:47 -0000 1.24 +++ lib/libc/net/ethers.c 8 Aug 2016 01:28:39 -0000 @@ -93,7 +93,7 @@ } int -ether_ntohost(char *hostname, struct ether_addr *e) +ether_ntohost(char *hostname, const struct ether_addr *e) { FILE *f; char buf[BUFSIZ+1], *p; @@ -144,7 +144,7 @@ } #endif if (ether_line(buf, &try, hostname) == 0 && - memcmp((void *)&try, (void *)e, sizeof(try)) == 0) { + memcmp((void *)&try, (const void *)e, sizeof(try)) == 0) { (void)fclose(f); return (0); } Index: sys/netinet/if_ether.h =================================================================== RCS file: /cvs/src/sys/netinet/if_ether.h,v retrieving revision 1.72 diff -u -r1.72 if_ether.h --- sys/netinet/if_ether.h 28 Jun 2016 17:18:24 -0000 1.72 +++ sys/netinet/if_ether.h 8 Aug 2016 01:28:48 -0000 @@ -316,7 +316,7 @@ __BEGIN_DECLS char *ether_ntoa(struct ether_addr *); struct ether_addr *ether_aton(const char *); -int ether_ntohost(char *, struct ether_addr *); +int ether_ntohost(char *, const struct ether_addr *); int ether_hostton(const char *, struct ether_addr *); int ether_line(const char *, struct ether_addr *, char *); __END_DECLS dmesg: OpenBSD 5.9 (GENERIC.MP) #1888: Fri Feb 26 01:20:19 MST 2016 dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP real mem = 4278124544 (4079MB) avail mem = 4144267264 (3952MB) mpath0 at root scsibus0 at mpath0: 256 targets mainbus0 at root bios0 at mainbus0: SMBIOS rev. 2.7 @ 0xe0010 (242 entries) bios0: vendor Phoenix Technologies LTD version "6.00" date 07/02/2015 bios0: VMware, Inc. VMware Virtual Platform acpi0 at bios0: rev 2 acpi0: sleep states S0 S1 S4 S5 acpi0: tables DSDT FACP BOOT APIC MCFG SRAT HPET WAET acpi0: wakeup devices PCI0(S3) USB_(S1) P2P0(S3) S1F0(S3) S2F0(S3) S3F0(S3) S4F0(S3) S5F0(S3) S6F0(S3) S7F0(S3) S8F0(S3) S9F0(S3) S10F(S3) S11F(S3) S12F(S3) S13F(S3) [...] acpitimer0 at acpi0: 3579545 Hz, 24 bits acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat cpu0 at mainbus0: apid 0 (boot processor) cpu0: Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz, 2794.30 MHz cpu0: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,MMX,FXSR,SSE,SSE2,SS,SSE3,PCLMUL,SSSE3,FMA3,CX16,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,HV,NXE,PAGE1GB,LONG,LAHF,ABM,PERF,ITSC,FSGSBASE,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,SENSOR,ARAT cpu0: 256KB 64b/line 8-way L2 cache cpu0: smt 0, core 0, package 0 mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges cpu0: apic clock running at 65MHz cpu1 at mainbus0: apid 2 (application processor) cpu1: Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz, 2794.03 MHz cpu1: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,MMX,FXSR,SSE,SSE2,SS,SSE3,PCLMUL,SSSE3,FMA3,CX16,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,HV,NXE,PAGE1GB,LONG,LAHF,ABM,PERF,ITSC,FSGSBASE,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,SENSOR,ARAT cpu1: 256KB 64b/line 8-way L2 cache cpu1: smt 0, core 0, package 2 ioapic0 at mainbus0: apid 1 pa 0xfec00000, version 11, 24 pins acpimcfg0 at acpi0 addr 0xf0000000, bus 0-127 acpihpet0 at acpi0: 14318179 Hz acpiprt0 at acpi0: bus 0 (PCI0) acpicpu0 at acpi0: C1(@1 halt!) acpicpu1 at acpi0: C1(@1 halt!) acpibat0 at acpi0: BAT1 not present acpibat1 at acpi0: BAT2 not present acpiac0 at acpi0: AC unit online acpibtn0 at acpi0: SLPB acpibtn1 at acpi0: LID_ pvbus0 at mainbus0: VMware vmt0 at pvbus0 pci0 at mainbus0 bus 0 pchb0 at pci0 dev 0 function 0 "Intel 82443BX AGP" rev 0x01 ppb0 at pci0 dev 1 function 0 "Intel 82443BX AGP" rev 0x01 pci1 at ppb0 bus 1 pcib0 at pci0 dev 7 function 0 "Intel 82371AB PIIX4 ISA" rev 0x08 pciide0 at pci0 dev 7 function 1 "Intel 82371AB IDE" rev 0x01: DMA, channel 0 configured to compatibility, channel 1 configured to compatibility wd0 at pciide0 channel 0 drive 0: <VMware Virtual IDE Hard Drive> wd0: 64-sector PIO, LBA, 8192MB, 16777216 sectors wd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 2 atapiscsi0 at pciide0 channel 1 drive 0 scsibus1 at atapiscsi0: 2 targets cd0 at scsibus1 targ 0 lun 0: <NECVMWar, VMware IDE CDR10, 1.00> ATAPI 5/cdrom removable cd0(pciide0:1:0): using PIO mode 4, Ultra-DMA mode 2 piixpm0 at pci0 dev 7 function 3 "Intel 82371AB Power" rev 0x08: SMBus disabled "VMware VMCI" rev 0x10 at pci0 dev 7 function 7 not configured vga1 at pci0 dev 15 function 0 "VMware SVGA II" rev 0x00 wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation) wsdisplay0: screen 1-5 added (80x25, vt100 emulation) ppb1 at pci0 dev 17 function 0 "VMware PCI" rev 0x02 pci2 at ppb1 bus 2 uhci0 at pci2 dev 0 function 0 "VMware UHCI" rev 0x00: apic 1 int 18 em0 at pci2 dev 1 function 0 "Intel 82545EM" rev 0x01: apic 1 int 19, address 00:0c:29:bd:8a:04 eap0 at pci2 dev 2 function 0 "Ensoniq AudioPCI97" rev 0x02: apic 1 int 16 ac97: codec id 0x43525913 (Cirrus Logic CS4297A rev 3) audio0 at eap0 midi0 at eap0: <AudioPCI MIDI UART> ehci0 at pci2 dev 3 function 0 "VMware EHCI" rev 0x00: apic 1 int 17 usb0 at ehci0: USB revision 2.0 uhub0 at usb0 "VMware EHCI root hub" rev 2.00/1.00 addr 1 usb1 at uhci0: USB revision 1.0 uhub1 at usb1 "VMware UHCI root hub" rev 1.00/1.00 addr 1 ppb2 at pci0 dev 21 function 0 "VMware PCIE" rev 0x01 pci3 at ppb2 bus 3 ppb3 at pci0 dev 21 function 1 "VMware PCIE" rev 0x01 pci4 at ppb3 bus 4 ppb4 at pci0 dev 21 function 2 "VMware PCIE" rev 0x01 pci5 at ppb4 bus 5 ppb5 at pci0 dev 21 function 3 "VMware PCIE" rev 0x01 pci6 at ppb5 bus 6 ppb6 at pci0 dev 21 function 4 "VMware PCIE" rev 0x01 pci7 at ppb6 bus 7 ppb7 at pci0 dev 21 function 5 "VMware PCIE" rev 0x01 pci8 at ppb7 bus 8 ppb8 at pci0 dev 21 function 6 "VMware PCIE" rev 0x01 pci9 at ppb8 bus 9 ppb9 at pci0 dev 21 function 7 "VMware PCIE" rev 0x01 pci10 at ppb9 bus 10 ppb10 at pci0 dev 22 function 0 "VMware PCIE" rev 0x01 pci11 at ppb10 bus 11 ppb11 at pci0 dev 22 function 1 "VMware PCIE" rev 0x01 pci12 at ppb11 bus 12 ppb12 at pci0 dev 22 function 2 "VMware PCIE" rev 0x01 pci13 at ppb12 bus 13 ppb13 at pci0 dev 22 function 3 "VMware PCIE" rev 0x01 pci14 at ppb13 bus 14 ppb14 at pci0 dev 22 function 4 "VMware PCIE" rev 0x01 pci15 at ppb14 bus 15 ppb15 at pci0 dev 22 function 5 "VMware PCIE" rev 0x01 pci16 at ppb15 bus 16 ppb16 at pci0 dev 22 function 6 "VMware PCIE" rev 0x01 pci17 at ppb16 bus 17 ppb17 at pci0 dev 22 function 7 "VMware PCIE" rev 0x01 pci18 at ppb17 bus 18 ppb18 at pci0 dev 23 function 0 "VMware PCIE" rev 0x01 pci19 at ppb18 bus 19 ppb19 at pci0 dev 23 function 1 "VMware PCIE" rev 0x01 pci20 at ppb19 bus 20 ppb20 at pci0 dev 23 function 2 "VMware PCIE" rev 0x01 pci21 at ppb20 bus 21 ppb21 at pci0 dev 23 function 3 "VMware PCIE" rev 0x01 pci22 at ppb21 bus 22 ppb22 at pci0 dev 23 function 4 "VMware PCIE" rev 0x01 pci23 at ppb22 bus 23 ppb23 at pci0 dev 23 function 5 "VMware PCIE" rev 0x01 pci24 at ppb23 bus 24 ppb24 at pci0 dev 23 function 6 "VMware PCIE" rev 0x01 pci25 at ppb24 bus 25 ppb25 at pci0 dev 23 function 7 "VMware PCIE" rev 0x01 pci26 at ppb25 bus 26 ppb26 at pci0 dev 24 function 0 "VMware PCIE" rev 0x01 pci27 at ppb26 bus 27 ppb27 at pci0 dev 24 function 1 "VMware PCIE" rev 0x01 pci28 at ppb27 bus 28 ppb28 at pci0 dev 24 function 2 "VMware PCIE" rev 0x01 pci29 at ppb28 bus 29 ppb29 at pci0 dev 24 function 3 "VMware PCIE" rev 0x01 pci30 at ppb29 bus 30 ppb30 at pci0 dev 24 function 4 "VMware PCIE" rev 0x01 pci31 at ppb30 bus 31 ppb31 at pci0 dev 24 function 5 "VMware PCIE" rev 0x01 pci32 at ppb31 bus 32 ppb32 at pci0 dev 24 function 6 "VMware PCIE" rev 0x01 pci33 at ppb32 bus 33 ppb33 at pci0 dev 24 function 7 "VMware PCIE" rev 0x01 pci34 at ppb33 bus 34 isa0 at pcib0 isadma0 at isa0 pckbc0 at isa0 port 0x60/5 irq 1 irq 12 pckbd0 at pckbc0 (kbd slot) wskbd0 at pckbd0: console keyboard, using wsdisplay0 pms0 at pckbc0 (aux slot) wsmouse0 at pms0 mux 0 pcppi0 at isa0 port 0x61 spkr0 at pcppi0 uhidev0 at uhub1 port 1 configuration 1 interface 0 "VMware VMware Virtual USB Mouse" rev 1.10/1.02 addr 2 uhidev0: iclass 3/0 ums0 at uhidev0: 16 buttons, Z and W dir wsmouse1 at ums0 mux 0 uhidev1 at uhub1 port 1 configuration 1 interface 1 "VMware VMware Virtual USB Mouse" rev 1.10/1.02 addr 2 uhidev1: iclass 3/0 ums1 at uhidev1: 16 buttons, Z and W dir wsmouse2 at ums1 mux 0 uhub2 at uhub1 port 2 "VMware VMware Virtual USB Hub" rev 1.10/1.00 addr 3 vscsi0 at root scsibus2 at vscsi0: 256 targets softraid0 at root scsibus3 at softraid0: 256 targets root on wd0a (a81ec63bd8da90dc.a) swap on wd0b dump on wd0b usbdevs: Controller /dev/usb0: addr 1: high speed, self powered, config 1, EHCI root hub(0x0000), VMware(0x15ad), rev 1.00 port 1 powered port 2 powered port 3 powered port 4 powered port 5 powered port 6 powered Controller /dev/usb1: addr 1: full speed, self powered, config 1, UHCI root hub(0x0000), VMware(0x15ad), rev 1.00 port 1 addr 2: full speed, self powered, config 1, VMware Virtual USB Mouse(0x0003), VMware(0x0e0f), rev 1.02 port 2 addr 3: full speed, self powered, config 1, VMware Virtual USB Hub(0x0002), VMware(0x0e0f), rev 1.00 port 1 powered port 2 powered port 3 powered port 4 powered port 5 powered port 6 powered port 7 powered