Re: [PATCH] Use size_t for variable list size and length
On 12/01/2012 02:47 AM, Chet Ramey wrote: On 11/29/12 5:07 AM, Roman Rakus wrote: see https://www.securecoding.cert.org/confluence/display/seccode/INT32-C.+Ensure+that+operations+on+signed+integers+do+not+result+in+overflow I've actually read this. I'm skeptical that this change has any practical effect at all. I'd like to see a case where the use of ints in this struct causes overflow, even on a 32-bit machine. Chet Hi chet, you're right, it has no practical effect - rather esthetical. If I'm calculating it well the case should contain more than 536870912 variables (2^32/8). I have no access to 32-bit machine right now, but I can try to run following script: for ((i=0; i<$((2**32/8 +1)); i++)) do eval "a$i=a$i" done RR
Re: Some globstar patterns produce duplicate entries and a null filename
On 12/01/2012 04:41 PM, Ulf Magnusson wrote: GNU bash, version 4.2.24(1)-release (i686-pc-linux-gnu) Take the following example, assumed to be run in an empty directory: $ mkdir a $ echo ** a $ echo **/** a a $ echo **/**/** a a a I would expect the result to be just 'a' in all cases. You also get back a null filename, as shown by $ for f in **/**/**; do echo "'$f'"; done '' 'a' 'a' 'a' /Ulf I can't reproduce it on my Fedora with bash 4.2.10 nor 4.2.39. Tried turn on and off extglob shell option. Can you please resend your report with `bashbug' script? Or at least say which linux distribution you are using? RR
Re: Some globstar patterns produce duplicate entries and a null filename
On Sun, Dec 2, 2012 at 4:58 PM, Roman Rakus wrote: > On 12/01/2012 04:41 PM, Ulf Magnusson wrote: >> >> GNU bash, version 4.2.24(1)-release (i686-pc-linux-gnu) >> >> Take the following example, assumed to be run in an empty directory: >> >> $ mkdir a >> $ echo ** >> a >> $ echo **/** >> a a >> $ echo **/**/** >> a a a >> >> I would expect the result to be just 'a' in all cases. >> >> You also get back a null filename, as shown by >> >> $ for f in **/**/**; do echo "'$f'"; done >> '' >> 'a' >> 'a' >> 'a' >> >> /Ulf >> > I can't reproduce it on my Fedora with bash 4.2.10 nor 4.2.39. Tried turn on > and off extglob shell option. > Can you please resend your report with `bashbug' script? Or at least say > which linux distribution you are using? > > RR > Ubuntu 12.04. My configuration is https://github.com/ulfalizer/Configuration-files/blob/master/bash, which I 'source' from the standard Ubuntu ~/.bash. I noticed the bug while implementing the _super_glob function. bashbug information: Machine: i686 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I../bash -I../bash/include -I../bash/lib -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -Wall uname output: Linux Huvuddator 3.2.0-32-generic-pae #51-Ubuntu SMP Wed Sep 26 21:54:23 UTC 2012 i686 i686 i386 GNU/Linux Machine Type: i686-pc-linux-gnu /Ulf
Re: Some globstar patterns produce duplicate entries and a null filename
On Sun, Dec 2, 2012 at 5:40 PM, Ulf Magnusson wrote: > On Sun, Dec 2, 2012 at 4:58 PM, Roman Rakus wrote: >> On 12/01/2012 04:41 PM, Ulf Magnusson wrote: >>> >>> GNU bash, version 4.2.24(1)-release (i686-pc-linux-gnu) >>> >>> Take the following example, assumed to be run in an empty directory: >>> >>> $ mkdir a >>> $ echo ** >>> a >>> $ echo **/** >>> a a >>> $ echo **/**/** >>> a a a >>> >>> I would expect the result to be just 'a' in all cases. >>> >>> You also get back a null filename, as shown by >>> >>> $ for f in **/**/**; do echo "'$f'"; done >>> '' >>> 'a' >>> 'a' >>> 'a' >>> >>> /Ulf >>> >> I can't reproduce it on my Fedora with bash 4.2.10 nor 4.2.39. Tried turn on >> and off extglob shell option. >> Can you please resend your report with `bashbug' script? Or at least say >> which linux distribution you are using? >> >> RR >> > > Ubuntu 12.04. My configuration is > https://github.com/ulfalizer/Configuration-files/blob/master/bash, > which I 'source' from the standard Ubuntu ~/.bash. I noticed the bug > while implementing the _super_glob function. > > bashbug information: > > Machine: i686 > OS: linux-gnu > Compiler: gcc > Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' > -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu' > -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' > -DSHELL -DHAVE_CONFIG_H -I. -I../bash -I../bash/include > -I../bash/lib -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector > --param=ssp-buffer-size=4 -Wformat -Wformat-security > -Werror=format-security -Wall > uname output: Linux Huvuddator 3.2.0-32-generic-pae #51-Ubuntu SMP Wed > Sep 26 21:54:23 UTC 2012 i686 i686 i386 GNU/Linux > Machine Type: i686-pc-linux-gnu > > /Ulf Left out some bashbug information: Bash Version: 4.2 Patch Level: 24 Release Status: release /Ulf
Re: Some globstar patterns produce duplicate entries and a null filename
On Sun, Dec 2, 2012 at 5:42 PM, Ulf Magnusson wrote: > On Sun, Dec 2, 2012 at 5:40 PM, Ulf Magnusson wrote: >> On Sun, Dec 2, 2012 at 4:58 PM, Roman Rakus wrote: >>> On 12/01/2012 04:41 PM, Ulf Magnusson wrote: GNU bash, version 4.2.24(1)-release (i686-pc-linux-gnu) Take the following example, assumed to be run in an empty directory: $ mkdir a $ echo ** a $ echo **/** a a $ echo **/**/** a a a I would expect the result to be just 'a' in all cases. You also get back a null filename, as shown by $ for f in **/**/**; do echo "'$f'"; done '' 'a' 'a' 'a' /Ulf >>> I can't reproduce it on my Fedora with bash 4.2.10 nor 4.2.39. Tried turn on >>> and off extglob shell option. >>> Can you please resend your report with `bashbug' script? Or at least say >>> which linux distribution you are using? >>> >>> RR >>> >> >> Ubuntu 12.04. My configuration is >> https://github.com/ulfalizer/Configuration-files/blob/master/bash, >> which I 'source' from the standard Ubuntu ~/.bash. I noticed the bug >> while implementing the _super_glob function. >> >> bashbug information: >> >> Machine: i686 >> OS: linux-gnu >> Compiler: gcc >> Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' >> -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu' >> -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' >> -DSHELL -DHAVE_CONFIG_H -I. -I../bash -I../bash/include >> -I../bash/lib -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector >> --param=ssp-buffer-size=4 -Wformat -Wformat-security >> -Werror=format-security -Wall >> uname output: Linux Huvuddator 3.2.0-32-generic-pae #51-Ubuntu SMP Wed >> Sep 26 21:54:23 UTC 2012 i686 i686 i386 GNU/Linux >> Machine Type: i686-pc-linux-gnu >> >> /Ulf > > Left out some bashbug information: > > Bash Version: 4.2 > Patch Level: 24 > Release Status: release > > /Ulf Oh - you need to enable 'globstar', not 'extglob'. :) /Ulf
IFS is ignored for nested functions with stdin redirection
I hit this problem in DKMS code and could reduce it to the following example: == #!/bin/bash oifs=$IFS inner () { echo a/b/c/d exit 0 } outer() { for i in 1; do IFS=/ read m v k a < <(IFS=$oifs inner) echo $m:$v:$k:$a done } outer for j in 1; do IFS=: read a b c d done < <(outer) echo $a-$b-$c-$d = bor@opensuse:/tmp> ./t a:b:c:d a/b/c/d--- bor@opensuse:/tmp> = Now insert *any* redirection before call to inner in outer function. It magically starts to work again: = #!/bin/bash oifs=$IFS inner () { echo a/b/c/d exit 0 } outer() { for i in 1; do : > /dev/null IFS=/ read m v k a < <(inner) echo $m:$v:$k:$a done } outer for j in 1; do IFS=: read a b c d done < <(outer) echo $a-$b-$c-$d bor@opensuse:/tmp> ./t a:b:c:d a-b-c-d bor@opensuse:/tmp> This is bash on openSUSE 12.2, bash-4.2-51.6.1.x86_64. Anyone can reproduce it as well? -andrey
Re: IFS is ignored for nested functions with stdin redirection
В Sun, 2 Dec 2012 20:52:00 +0400 Andrey Borzenkov пишет: > I hit this problem in DKMS code and could reduce it to the following > example: > > == > #!/bin/bash > > oifs=$IFS > > inner () { > echo a/b/c/d > exit 0 > } > > outer() { > for i in 1; do > IFS=/ read m v k a < <(IFS=$oifs inner) > > echo $m:$v:$k:$a > done > } > > outer > > for j in 1; do > IFS=: read a b c d > done < <(outer) > > echo $a-$b-$c-$d > = > bor@opensuse:/tmp> ./t > a:b:c:d > a/b/c/d--- > bor@opensuse:/tmp> > = > > > Now insert *any* redirection before call to inner in outer function. > It magically starts to work again: > > = > #!/bin/bash > > oifs=$IFS > > inner () { > echo a/b/c/d > exit 0 > } > > outer() { > for i in 1; do > : > /dev/null > IFS=/ read m v k a < <(inner) > > echo $m:$v:$k:$a > done > } > > outer > > for j in 1; do > IFS=: read a b c d > done < <(outer) > > echo $a-$b-$c-$d > > bor@opensuse:/tmp> ./t > a:b:c:d > a-b-c-d > bor@opensuse:/tmp> > > > This is bash on openSUSE 12.2, bash-4.2-51.6.1.x86_64. Anyone can > reproduce it as well? > The bug is present in current GIT head and is not present in GIT tag bash-4.0. Unfortunately attempt to bisect it choked in the middle where bash does not compile. Here is bisect log: bor@opensuse:~/src/bash> git bisect log git bisect start # bad: [11d0fdf779380d2951b9ff0cc37a6872cb1a7438] Bash-4.2 patch 39 git bisect bad 11d0fdf779380d2951b9ff0cc37a6872cb1a7438 # good: [89a92869e56aba4e4cab2d639c00a86f0545c862] Bash-4.0 patchlevel 38 git bisect good 89a92869e56aba4e4cab2d639c00a86f0545c862 # bad: [b4d40164691e23c7c546daa57c411907a2c2e8cf] Bash-4.2 patch 17 git bisect bad b4d40164691e23c7c546daa57c411907a2c2e8cf # bad: [eafc91a3506a082956fbdc8f0fb1210d00f1e035] Bash-4.2 patch 6 git bisect bad eafc91a3506a082956fbdc8f0fb1210d00f1e035 # bad: [49ed961bb057ad481b8f22066d55526ecdfb3c09] Bash-4.2 patch 1 git bisect bad 49ed961bb057ad481b8f22066d55526ecdfb3c09 # skip: [30d188c2932d6ef609d894fefeb7e7b03ccff463] Bash-4.1 patchlevel 11 git bisect skip 30d188c2932d6ef609d894fefeb7e7b03ccff463 # bad: [495aee441b75276e38c75694ccb455bb6463fdb9] Bash-4.2 distribution sources and documentation git bisect bad 495aee441b75276e38c75694ccb455bb6463fdb9 bor@opensuse:~/src/bash> Current commit does not compile 0001803f0b9523c94fa2ede48eaecb047fef4524 I also could not compile commit 30d188c2932d6ef609d894fefeb7e7b03ccff463 and had to skip it.
Re: Some globstar patterns produce duplicate entries and a null filename
On 12/02/2012 05:57 PM, Ulf Magnusson wrote: Oh - you need to enable 'globstar', not 'extglob'.:) /Ulf Yes, you're right. Bash incorrectly expands to empty string and duplicated results. RR
Re: IFS is ignored for nested functions with stdin redirection
On 12/2/12 11:52 AM, Andrey Borzenkov wrote: > I hit this problem in DKMS code and could reduce it to the following > example: Thanks for the report. The problem has to do with state in the process substitution subshell preventing it from using the temporary environment for variable lookups. It will be fixed in the next version. I have attached a patch; please let me know if it fixes the issue for you. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/ *** ../bash-4.2-patched/subst.c 2012-07-14 15:53:20.0 -0400 --- subst.c 2012-12-02 22:26:54.0 -0500 *** *** 5125,5128 --- 5129,5136 #endif /* HAVE_DEV_FD */ + /* subshells shouldn't have this flag, which controls using the temporary + environment for variable lookups. */ + expanding_redir = 0; + result = parse_and_execute (string, "process substitution", (SEVAL_NONINT|SEVAL_NOHIST));