From owner-freebsd-hackers@FreeBSD.ORG Tue Feb 16 17:01:29 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E76CA106566C for ; Tue, 16 Feb 2010 17:01:29 +0000 (UTC) (envelope-from yanefbsd@gmail.com) Received: from mail-pz0-f202.google.com (mail-pz0-f202.google.com [209.85.222.202]) by mx1.freebsd.org (Postfix) with ESMTP id BA3C98FC0A for ; Tue, 16 Feb 2010 17:01:29 +0000 (UTC) Received: by pzk40 with SMTP id 40so3415914pzk.7 for ; Tue, 16 Feb 2010 09:01:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=SlhBSGTfcaurp68wJeIjSPtbmNuv+MjRWiARh6viueA=; b=nUDTEPneyoY/fWDGQTuNsYTDpq5xe6WzjPZ4D/GIq+0mKp7XX2lNztWdAOENKkdQgx 0xkpYcv0YNDYrdroj34MWNhFISwVkHUPSn7Ycu4xvWR/CMP5KHHXI9yqMgPzSPEuN7kw UsOHLILl7Snh3CS85L1AA3anj/ualk+kMgV8Q= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=Are2ilE8DX8YRGrHjA2u17ADKT4BCvuglrZVImZOPvoLrIw4Bd4ko/6OQ3y3IuBulR lANLcF8R17WcCIRM0cDfhLMw+Sf6IUupr6T2updS+8xG2S6Kq7YCQgoR7yO2t+hCruGq 1cthVAy/HDIo5TQ4ZZHrF+pT+X26wA3giHGtQ= MIME-Version: 1.0 Received: by 10.142.55.13 with SMTP id d13mr4513989wfa.50.1266339689134; Tue, 16 Feb 2010 09:01:29 -0800 (PST) In-Reply-To: References: <364299f41002151649y2e4d4120p918759afb1fd8f6c@mail.gmail.com> <7d6fde3d1002151655q184c8a21k8a0c6c07b9b0ae79@mail.gmail.com> Date: Tue, 16 Feb 2010 09:01:29 -0800 Message-ID: <7d6fde3d1002160901r600bb514u4a3219d2e59b16aa@mail.gmail.com> From: Garrett Cooper To: Jan Mikkelsen Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: FreeBSD-Hackers Subject: Re: read(1) garbage when input redirected from make incorrectly X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Feb 2010 17:01:30 -0000 On Mon, Feb 15, 2010 at 5:45 PM, Jan Mikkelsen w= rote: > On 16/02/2010, at 11:55 AM, Garrett Cooper wrote: > >> Hi Hackers, >> =A0 =A0I accidentally reproduced the following after executing read >> properly in a pipeline with make: >> >> [garrcoop@garrcoop-fbsd /usr/home/garrcoop]$ read DESTDIR SRCCONF < >> /usr/bin/make -V DESTDIR -V SRCCONF >> bash: read: `-V': not a valid identifier >> [garrcoop@garrcoop-fbsd /usr/home/garrcoop]$ echo $DESTDIR >> =A0ELF >> [garrcoop@garrcoop-fbsd /usr/home/garrcoop]$ hexdump -C foo >> 00000000 =A07f 45 4c 46 01 01 01 0a =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 |.ELF....| >> 00000008 >> [garrcoop@garrcoop-fbsd /usr/home/garrcoop]$ >> >> =A0 =A0Is this an issue to be concerned about apart from cosmetic noise, >> i.e. potential buffer access problem? I see the same garbage from >> bash/coreutils on RHEL 4.6 as well as read(1) and /bin/sh on FreeBSD >> with RELENG_8, so the issue appears to be consistent on multiple >> OSes... >> Thanks, >> -Garrett > > I think you meant to type: > > =A0 =A0make -V DESTDIR -V SRCCONF | read DESTDIR SRCCONF > > What you are actually doing is feeding the contents of the make binary in= to: > > =A0 =A0read DESTDIR SRCCONF -V DESTDIR -V SRCCONF > > and the shell is correctly complaining about '-V' not being a valid ident= ifier, and populating DESTDIR with data it got from the binary. Yes, now it all makes sense to me. It's just interesting why read (1) is the only thing I've found (so far) that has this behavior, but it's probably a biproduct of how it scans its arguments on stdin: [gcooper@optimus ~]$ python -c 'import sys; sys.stdin.read()' < make -V bash: make: No such file or directory [gcooper@optimus ~]$ perl -e 'while (<>) { print; }' < make -V bash: make: No such file or directory Thanks, -Garrett