From owner-freebsd-bugs@FreeBSD.ORG Sat Jan 10 09:20:03 2009 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 146CF106566C for ; Sat, 10 Jan 2009 09:20:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 036A98FC0A for ; Sat, 10 Jan 2009 09:20:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n0A9K2S7044943 for ; Sat, 10 Jan 2009 09:20:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n0A9K2xP044942; Sat, 10 Jan 2009 09:20:02 GMT (envelope-from gnats) Date: Sat, 10 Jan 2009 09:20:02 GMT Message-Id: <200901100920.n0A9K2xP044942@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Jaakko Heinonen Cc: Subject: Re: bin/124724: [patch] netstat(1): netstat coredump on -stable X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Jaakko Heinonen List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Jan 2009 09:20:03 -0000 The following reply was made to PR bin/124724; it has been noted by GNATS. From: Jaakko Heinonen To: Li yonggang Cc: bug-followup@FreeBSD.org Subject: Re: bin/124724: [patch] netstat(1): netstat coredump on -stable Date: Sat, 10 Jan 2009 11:11:18 +0200 Hi, On 2009-01-09, Li yonggang wrote: > your analysis is correct for netstat -m -N foo. > but for netstat -m foo.I think it is caused by not checking the input, > which is definitely not a good habit and bug latency. > So a input check should be done as soon as possible. > I combined the fixes of yours and mine to fix these 2 problems. I am not sure if I understand what you mean with "input checking" but I suspect that you mean checking of all command line arguments. netstat accepts for example following command line: $ netstat /boot/kernel/kernel /var/crash/vmcore.1 1 2 3 4 5 It doesn't complain about extra command line arguments. However I disagree that my analysis is incorrect about the segfault with "netstat -m foo" command line. The crash happens in libkvm because kvm_openfiles() is called with non-NULL nlistf and NULL memf. My patch adds a check for this case and netstat aborts with an error message before any kvm(3) calls. I agree that it may be a good idea to remove the old backward compatibility code for an ancient (undocumented?) syntax for specifying some parameters without options provided that no one uses the syntax. It's also reasonable to give an error if superfluous command line arguments are given. -- Jaakko