From owner-freebsd-stable Mon Oct 28 19:22: 7 2002 Delivered-To: freebsd-stable@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5034137B401 for ; Mon, 28 Oct 2002 19:22:05 -0800 (PST) Received: from be-well.ilk.org (lowellg.ne.client2.attbi.com [24.147.188.198]) by mx1.FreeBSD.org (Postfix) with ESMTP id 80D4D43E9C for ; Mon, 28 Oct 2002 19:22:04 -0800 (PST) (envelope-from freebsd-stable-local@be-well.no-ip.com) Received: from be-well.ilk.org (lowellg.ne.client2.attbi.com [24.147.188.198] (may be forged)) by be-well.ilk.org (8.12.6/8.12.5) with ESMTP id g9T3M3WJ052055; Mon, 28 Oct 2002 22:22:03 -0500 (EST) (envelope-from freebsd-stable-local@be-well.no-ip.com) Received: (from lowell@localhost) by be-well.ilk.org (8.12.6/8.12.6/Submit) id g9T3M35p052052; Mon, 28 Oct 2002 22:22:03 -0500 (EST) X-Authentication-Warning: be-well.ilk.org: lowell set sender to freebsd-stable-local@be-well.ilk.org using -f To: "Charles Swiger" Cc: , Subject: Re: last cores References: <44smyq9r4m.fsf@be-well.ilk.org> <000701c27ecd$4ba3d9e0$0301a8c0@prime> From: Lowell Gilbert Date: 28 Oct 2002 22:22:03 -0500 In-Reply-To: <000701c27ecd$4ba3d9e0$0301a8c0@prime> Message-ID: <44lm4i7wv8.fsf@be-well.ilk.org> Lines: 58 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-freebsd-stable@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG "Charles Swiger" writes: > From: "Lowell Gilbert" > > Bryan Fullerton writes: > >> Someone might want to look at this. > >> > >> % last -w0 > >> Segmentation fault (core dumped) > >> > >> Does this on 4.6.2-RELEASE-p2, 4.7-RELEASE, 4.7-STABLE (Oct 17). > > > > Doesn't belong the -security list, but it looks like the > > backward-compatibility hack in the option-handling switch > > statement of last.c needs another hack. > > The example in the getopt(3) manpage should probably be reviewed for > correctness as well. Bryan, please see whether this helps: > > 5-sec# diff -w -c last.c_orig last.c > /usr/src/usr.bin/last > *** last.c_orig Mon Oct 28 08:41:16 2002 > --- last.c Mon Oct 28 09:10:18 2002 > *************** > *** 142,147 **** > --- 143,149 ---- > * a number after a dash. > */ > if (maxrec == -1) { > + if (optind == argc) break; > p = argv[optind - 1]; > if (p[0] == '-' && p[1] == ch && !p[2]) > maxrec = atol(++p); > This is still a serious hack (I'm not sure how else you can get into this case, but the code obviously thinks there's another way), but it at least shouldn't be broken for any cases that the original wasn't, and it fixes the specific one reported: *** /usr/src/usr.bin/last/last.c Tue Mar 12 15:09:29 2002 --- last.c Mon Oct 28 22:20:55 2002 *************** *** 145,151 **** p = argv[optind - 1]; if (p[0] == '-' && p[1] == ch && !p[2]) maxrec = atol(++p); ! else maxrec = atol(argv[optind] + 1); if (!maxrec) exit(0); --- 145,151 ---- p = argv[optind - 1]; if (p[0] == '-' && p[1] == ch && !p[2]) maxrec = atol(++p); ! else if (argv[optind]) maxrec = atol(argv[optind] + 1); if (!maxrec) exit(0); To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-stable" in the body of the message