>Synopsis: ntpd segfaults when parsing a configuration file with 'listen >on <hostname>' >Category: system >Environment: System : OpenBSD 5.0 Details : OpenBSD 5.0-current (GENERIC) #67: Tue Dec 20 19:32:57 MST 2011 dera...@loongson.openbsd.org:/usr/src/sys/arch/loongson/compile/GENERIC
Architecture: OpenBSD.loongson Machine : loongson >Description: when lannching ntpd whith ntpd.conf containing 'listen on <hostname>' ntpd crashes immediatly. >How-To-Repeat: echo listen on `hostname` >> /tmp/ntpd.conf ntpd -nf /tmp/ntpd.conf >Fix: this patch corrects this behavior. I initialized the address before calling 'host'. the other way arround is probably to ensure that the function 'host' gives NULL valued address when using hostnames. by the way 'host' doesn't return -1 so the test block in the second hunk ("could not parse address spec") is never reached. Index: usr.sbin/ntpd/parse.y =================================================================== RCS file: /cvs/src/usr.sbin/ntpd/parse.y,v retrieving revision 1.48 diff -u -r1.48 parse.y --- usr.sbin/ntpd/parse.y 21 Sep 2011 15:41:30 -0000 1.48 +++ usr.sbin/ntpd/parse.y 23 Dec 2011 17:50:52 -0000 @@ -102,7 +102,7 @@ struct listen_addr *la; struct ntp_addr *h, *next; - if ((h = $3->a) == NULL && (h->rtable = $4.rtable) && + if ((h = $3->a) == NULL && (host_dns($3->name, &h) == -1 || !h)) { yyerror("could not resolve \"%s\"", $3->name); free($3->name); @@ -220,6 +220,7 @@ if (($$ = calloc(1, sizeof(struct ntp_addr_wrap))) == NULL) fatal(NULL); + $$->a = NULL; if (host($1, &$$->a) == -1) { yyerror("could not parse address spec \"%s\"", $1); dmesg: OpenBSD 5.0-current (GENERIC) #67: Tue Dec 20 19:32:57 MST 2011 dera...@loongson.openbsd.org:/usr/src/sys/arch/loongson/compile/GENERIC real mem = 536870912 (512MB) avail mem = 526467072 (502MB) mainbus0 at root: Lemote Fuloong cpu0 at mainbus0: STC Loongson2F CPU 800 MHz, STC Loongson2F FPU cpu0: cache L1-I 64KB D 64KB 4 way, L2 512KB 4 way bonito0 at mainbus0: memory and PCI-X controller, rev 1 pci0 at bonito0 bus 0 re0 at pci0 dev 6 function 0 "Realtek 8169" rev 0x10: RTL8169/8110SCd (0x1800), irq 4, address 00:23:9e:00:10:51 rgephy0 at re0 phy 7: RTL8169S/8110S PHY, rev. 2 sisfb0 at pci0 dev 8 function 0 "SiS 315 Pro VGA" rev 0x00: 640x400x8 frame buffer wsdisplay0 at sisfb0 mux 1: console (std, vt100 emulation) glxpcib0 at pci0 dev 14 function 0 "AMD CS5536 ISA" rev 0x03: rev 3, 32-bit 3579545Hz timer, watchdog, gpio gpio1 at glxpcib0: 32 pins pciide0 at pci0 dev 14 function 2 "AMD CS5536 IDE" rev 0x01: DMA, channel 0 wired to compatibility, channel 1 wired to compatibility wd0 at pciide0 channel 0 drive 0: <WDC WD1600BEVT-22ZCT0> wd0: 16-sector PIO, LBA48, 152627MB, 312581808 sectors wd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 2 pciide0: channel 1 ignored (disabled) auglx0 at pci0 dev 14 function 3 "AMD CS5536 Audio" rev 0x01: isa irq 9, CS5536 AC97 ac97: codec id 0x414c4760 (Avance Logic ALC655 rev 0) audio0 at auglx0 ohci0 at pci0 dev 14 function 4 "AMD CS5536 USB" rev 0x02: isa irq 11, version 1.0, legacy support ehci0 at pci0 dev 14 function 5 "AMD CS5536 USB" rev 0x02: isa irq 11 usb0 at ehci0: USB revision 2.0 uhub0 at usb0 "AMD EHCI root hub" rev 2.00/1.00 addr 1 isa0 at glxpcib0 com0 at isa0 port 0x2f8/8 irq 3: ns16550a, 16 byte fifo com1 at isa0 port 0x3f8/8 irq 4: ns16550a, 16 byte fifo mcclock0 at isa0 port 0x70/2: mc146818 or compatible usb1 at ohci0: USB revision 1.0 uhub1 at usb1 "AMD OHCI root hub" rev 1.00/1.00 addr 1 clock0 at mainbus0: ticker on int5 using count register apm0 at mainbus0 vscsi0 at root scsibus0 at vscsi0: 256 targets softraid0 at root scsibus1 at softraid0: 256 targets pmon bootpath: /dev/disk/wd0 boot device: wd0 root on wd0a swap on wd0b dump on wd0b usbdevs: Controller /dev/usb0: addr 1: high speed, self powered, config 1, EHCI root hub(0x0000), AMD(0x1022), rev 1.00 port 1 powered port 2 powered port 3 powered port 4 powered Controller /dev/usb1: addr 1: full speed, self powered, config 1, OHCI root hub(0x0000), AMD(0x1022), rev 1.00 port 1 powered port 2 powered port 3 powered port 4 powered