lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210315230951.GA17229@gondor.apana.org.au>
Date:   Tue, 16 Mar 2021 10:09:51 +1100
From:   Herbert Xu <herbert@...dor.apana.org.au>
To:     Linus Torvalds <torvalds@...ux-foundation.org>
Cc:     Rong Chen <rong.a.chen@...el.com>,
        kernel test robot <lkp@...el.com>,
        Peter Oberparleiter <oberpar@...ux.ibm.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        kbuild-all@...ts.01.org,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [kbuild-all] Re: [PATCH] gcov: fail build on gcov_info size
 mismatch

On Mon, Mar 15, 2021 at 01:57:58PM -0700, Linus Torvalds wrote:
>
>     $ [ "!"  = ".size" -a "b" = ".LPBX0," ]
> 
> causes
> 
>     dash: 6: [: =: unexpected operator
> 
> because for some reason that "-a" ends up (wild handwaving here about
> what is going on) re-parsing the first expression, and ignoring the
> quoting around "!" when it does so.

The quoting on "!" doesn't help I'm afraid.  Even though [ is a
built-in it is not allowed to look at the quoting because it's
supposed to behave in the same way whether you get the builtin [
or the one from /usr/bin.

So when it gets the expression the quoting on the "!" has already
been removed.

IOW this expression is ambiguous and may or may not fail depending
on how it's parsed.

Note that when you have a simple expression like

	[ "!" = ".size" ]

special rules come into play on how it is parsed:

https://pubs.opengroup.org/onlinepubs/009604499/utilities/test.html

But this does not apply when you construct more complex ones with
-a.

There are two ways around this when writing scripts, you either
add something to ensure that "!" cannot occur, e.g.,

	[ "X$a" = "X$b" -a ... ]

or you break it down into a simpler expression that is guaranteed
by POSIX:

	[ "$a" = "$b" ] && [ ... ]

Cheers,
-- 
Email: Herbert Xu <herbert@...dor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ