All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Dan Kegel <dank@kegel.com>
Cc: dash@vger.kernel.org
Subject: Re: Crash on valid input
Date: Mon, 08 Apr 2013 21:08:16 -0600	[thread overview]
Message-ID: <51638620.4030603@redhat.com> (raw)
In-Reply-To: <CAPF-yOaPfWdK2c556eTcRuf-thaHEzUcMKa+xa8criaS8uFLUw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1972 bytes --]

On 04/08/2013 08:43 PM, Dan Kegel wrote:
> If I check for an empty string like this:
> 
> + test ! $foo

You know, this is highly reliant on $foo expanding to either nothing (it
is empty, so you are really invoking the one-argument form 'test !'
which is true) or a single shell word (the two-argument form 'test !
nonempty' is false).  But if $foo has embedded whitespace, it expands to
more than one word after word-splitting, and you're hosed ('test ! one
two' can give interesting results, and probably not what you were
expecting).

You might want to fix your script to just use the safer:

! test "$foo"

which works even if $foo has embedded whitespace.  That said, you are
correct that dash should never crash.

> 
> dash crashes.  This occurs both in the version shipped with ubuntu
> 10.04 and 12.04
> as well as with dash from git.
> 
> Here's the stack:
> 
> Program received signal SIGSEGV, Segmentation fault.
> __strcmp_sse4_2 () at ../sysdeps/i386/i686/multiarch/strcmp-sse4.S:221
> 221 ../sysdeps/i386/i686/multiarch/strcmp-sse4.S: No such file or directory.
> (gdb) bt
> #0  __strcmp_sse4_2 () at ../sysdeps/i386/i686/multiarch/strcmp-sse4.S:221
> #1  0x0805938a in getop (s=0x202b <Address 0x202b out of bounds>) at
> bltin/test.c:168
> #2  0x08059c91 in t_lex (tp=0x806581c) at bltin/test.c:431
> #3  0x080595cb in aexpr (n=UNOT) at bltin/test.c:260
> #4  0x08059557 in oexpr (n=UNOT) at bltin/test.c:243
> #5  0x080594ba in testcmd (argc=1, argv=0x8065814) at bltin/test.c:219
> #6  0x0804c526 in evalbltin (cmd=0x805da1c, argc=2, argv=0x8065810,
> flags=0) at eval.c:910

and given this part of the stack trace, it looks like you were invoking
'test ! word'?  But I was unable to reproduce a crash when I tried
dash.git, so it would be helpful to know exactly what $foo was in your
reproducer.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 621 bytes --]

  reply	other threads:[~2013-04-09  3:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-09  2:43 Crash on valid input Dan Kegel
2013-04-09  3:08 ` Eric Blake [this message]
2013-04-09  3:12   ` Dan Kegel
2013-04-09  3:27     ` Eric Blake
2013-04-09  3:34       ` Eric Blake
2013-04-09  3:44         ` Dan Kegel
2013-04-09 21:20       ` Harald van Dijk
2013-08-23 11:59         ` Herbert Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51638620.4030603@redhat.com \
    --to=eblake@redhat.com \
    --cc=dank@kegel.com \
    --cc=dash@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.