From owner-freebsd-net@FreeBSD.ORG Tue Jan 6 16:41:05 2009 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A93751065670 for ; Tue, 6 Jan 2009 16:41:05 +0000 (UTC) (envelope-from leeygang@gmail.com) Received: from fk-out-0910.google.com (fk-out-0910.google.com [209.85.128.189]) by mx1.freebsd.org (Postfix) with ESMTP id 396278FC16 for ; Tue, 6 Jan 2009 16:41:05 +0000 (UTC) (envelope-from leeygang@gmail.com) Received: by fk-out-0910.google.com with SMTP id k31so5358664fkk.11 for ; Tue, 06 Jan 2009 08:41:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type:content-transfer-encoding :content-disposition; bh=5r9SSeoWvCYmcSry9vupSiXd4hYZvjk0ivDr6+WGeWQ=; b=JsKAhIZrsNP83YEkM0TMyjOlGib12SKzjwVO+AkG5c/qX5As6Q0c2AUaAoBqMCkCje 6TT9NRpP3J6+mIGDKFqAB48IUGiQVxM0BgYJJKSgicZKKLQJpoecWAUxSIe9U3XgeL1H LonaUCrRrN35SVzNuB1/IOmfqmDCznP7pJ9F8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type :content-transfer-encoding:content-disposition; b=wePpPOeAjCB2oIS+hiBJGnHVrZDTAE/+U9K/9T3kmmfgRwD67E634cLzQWqT2vDnW0 Nflkt9ZLkdWYCaVPXNZ4NTo9WEq3Fz2vwwUBiKAF+IGYCL2Fc6vlSwiWdJKGB5i71MSO lvBXDyRTA91tch59ZoqIFoXIXtlEAYvy2zWXw= Received: by 10.103.217.5 with SMTP id u5mr3866019muq.118.1231258366356; Tue, 06 Jan 2009 08:12:46 -0800 (PST) Received: by 10.103.95.8 with HTTP; Tue, 6 Jan 2009 08:12:46 -0800 (PST) Message-ID: <6742fb710901060812u5f1b749cubec97c8adbbe3384@mail.gmail.com> Date: Tue, 6 Jan 2009 16:12:46 +0000 From: "Li yonggang" To: freebsd-net@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Subject: the BACKWARD COMPTIBLITY code for the input for netstat leads to a crash X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Jan 2009 16:41:06 -0000 Hi, I use FreeBSD 7.0-Release and find if a mistake input for -m can make netstat crash. such as: netstat -m xxx After simple investigation, I found it is caused by the code in main.c :456 #define BACKWARD_COMPATIBILITY #ifdef BACKWARD_COMPATIBILITY if (*argv) { if (isdigit(**argv)) { interval = atoi(*argv); if (interval <= 0) usage(); ++argv; iflag = 1; } if (*argv) { nlistf = *argv; if (*++argv) memf = *argv; } } #endif if the input is incorrect, this piece of code will set nlistf as a incorrect string, this will make the live var set incorrectly. so I think there are 2 ways to resolve: 1. add input check code in case -m of switch. 2. or delete backward comptiblity code. Is my understanding correct? Thanks, Yong-gang Li.