From owner-freebsd-bugs@FreeBSD.ORG Tue Sep 3 17:30:01 2013 Return-Path: Delivered-To: freebsd-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 2D073B0A for ; Tue, 3 Sep 2013 17:30:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 0D86F233D for ; Tue, 3 Sep 2013 17:30:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.7/8.14.7) with ESMTP id r83HU0SU010665 for ; Tue, 3 Sep 2013 17:30:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.7/8.14.7/Submit) id r83HU0Ff010664; Tue, 3 Sep 2013 17:30:00 GMT (envelope-from gnats) Resent-Date: Tue, 3 Sep 2013 17:30:00 GMT Resent-Message-Id: <201309031730.r83HU0Ff010664@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Fabian Keil Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id EDAF4909 for ; Tue, 3 Sep 2013 17:24:18 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from oldred.freebsd.org (oldred.freebsd.org [8.8.178.121]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id B4DC022EE for ; Tue, 3 Sep 2013 17:24:18 +0000 (UTC) Received: from oldred.freebsd.org ([127.0.1.6]) by oldred.freebsd.org (8.14.5/8.14.7) with ESMTP id r83HOIZD033473 for ; Tue, 3 Sep 2013 17:24:18 GMT (envelope-from nobody@oldred.freebsd.org) Received: (from nobody@localhost) by oldred.freebsd.org (8.14.5/8.14.5/Submit) id r83HOIpO033466; Tue, 3 Sep 2013 17:24:18 GMT (envelope-from nobody) Message-Id: <201309031724.r83HOIpO033466@oldred.freebsd.org> Date: Tue, 3 Sep 2013 17:24:18 GMT From: Fabian Keil To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Subject: bin/181783: [PATCH] nslookup segfaults after reading "^D" X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Sep 2013 17:30:01 -0000 >Number: 181783 >Category: bin >Synopsis: [PATCH] nslookup segfaults after reading "^D" >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Sep 03 17:30:00 UTC 2013 >Closed-Date: >Last-Modified: >Originator: Fabian Keil >Release: HEAD >Organization: >Environment: FreeBSD r500.local 10.0-CURRENT FreeBSD 10.0-CURRENT #596 r255153+2bda83d: Mon Sep 2 22:07:13 CEST 2013 fk@r500.local:/usr/obj/usr/src/sys/ZOEY amd64 >Description: The attached patch prevents nslookup from segfaulting after reading a single "^D" when running in interactive mode and built with readline support. >How-To-Repeat: fk@r500 ~ $gdb76 --args nslookup GNU gdb (GDB) 7.6 [GDB v7.6 for FreeBSD] [...] Reading symbols from /usr/bin/nslookup...done. (gdb) r Starting program: /usr/bin/nslookup [New LWP 101002] > ^D[New Thread 802006800 (LWP 101058)] Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 802006800 (LWP 101058)] strlen (str=0x0) at /usr/src/lib/libc/string/strlen.c:100 100 va = (*lp - mask01); (gdb) where #0 strlen (str=0x0) at /usr/src/lib/libc/string/strlen.c:100 #1 0x000000080149ef82 in strdup (str=0x0) at /usr/src/lib/libc/string/strdup.c:46 #2 0x00000008009eb529 in history_def_insert (ev=, str=0x0, h=) at /usr/src/lib/libedit/history.c:465 #3 history_def_enter (p=0x8024e7040, ev=0x7fffffbfdee0, str=0x0) at /usr/src/lib/libedit/history.c:497 #4 0x00000008009ebd71 in history (h=0x8024e5080, ev=0x7fffffbfdee0, fun=) at /usr/src/lib/libedit/history.c:953 #5 0x00000008009d7b18 in add_history (line=, line=) at /usr/src/lib/libedit/readline.c:1371 #6 0x000000000040efb5 in get_next_command () at /usr/src/usr.bin/nslookup/../../contrib/bind9/bin/dig/nslookup.c:770 #7 getinput (task=, event=) at /usr/src/usr.bin/nslookup/../../contrib/bind9/bin/dig/nslookup.c:869 #8 0x000000000054acaf in dispatch (manager=) at /usr/src/lib/bind/isc/../../../contrib/bind9/lib/isc/task.c:1116 #9 run (uap=0x802033000) at /usr/src/lib/bind/isc/../../../contrib/bind9/lib/isc/task.c:1286 #10 0x0000000800fee534 in thread_start (curthread=0x802006800) at /usr/src/lib/libthr/thread/thr_create.c:284 #11 0x0000000000000000 in ?? () >Fix: Patch attached with submission follows: >From 9f966878a610092dafade8950a32f789ca361f7f Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Tue, 3 Sep 2013 10:55:07 +0200 Subject: [PATCH] Prevent nslookup from segfaulting upon receiving ^D --- contrib/bind9/bin/dig/nslookup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contrib/bind9/bin/dig/nslookup.c b/contrib/bind9/bin/dig/nslookup.c index 3f5b82f..49aabed 100644 --- a/contrib/bind9/bin/dig/nslookup.c +++ b/contrib/bind9/bin/dig/nslookup.c @@ -767,7 +767,8 @@ get_next_command(void) { if (interactive) { #ifdef HAVE_READLINE ptr = readline("> "); - add_history(ptr); + if (ptr != NULL) + add_history(ptr); #else fputs("> ", stderr); fflush(stderr); -- 1.8.2.2 >Release-Note: >Audit-Trail: >Unformatted: