Rergession in readcmd (commit 55c46b7)
Greeting!
readcmd put trash in the variables.
Test case:
$ cat /tmp/conf Include common.conf FullSpeedCPU yes
$ cat /tmp/z.sh while read option params; do printf '[%s] [%s]\n' "$option" "$params" done < /tmp/conf
Result:
$ dash /tmp/z.sh [Include] [common.conf] [FullSpeedCPU] [yesFnf]
Signature · 1 line
Rgrds, legion
Quoted 15 lines · Alexey Gladkov
Greeting!
readcmd put trash in the variables.
Test case:
$ cat /tmp/conf Include common.conf FullSpeedCPU yes$ cat /tmp/z.sh while read option params; do printf '[%s] [%s]\n' "$option" "$params" done < /tmp/conf
Quoted 5 lines
Result:
$ dash /tmp/z.sh [Include] [common.conf] [FullSpeedCPU] [yesFnf]
Thanks for the report. It's an off-by-one error causing the NUL termination to disappear.
ChangeLog +4 -0
@@ -1,3 +1,7 @@ +2009-08-31 Herbert Xu <[email protected]> + + * Fix NUL termination in readcmd. + 2009-08-11 Herbert Xu <[email protected]> * Pass EV_TESTED into evalcmd.
src/miscbltin.c +1 -1
@@ -182,7 +182,7 @@ resetbs: backslash =0 ; }STACKSTRNUL (p); -readcmd_handle_line (stackblock (), ap, p - (char *)stackblock ()); +readcmd_handle_line (stackblock (), ap, p +1 - (char *)stackblock ());return status; }
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtQuoted 6 lines · Herbert Xu
Quoted 3 lines
$ dash /tmp/z.sh [Include] [common.conf] [FullSpeedCPU] [yesFnf]Thanks for the report. It's an off-by-one error causing the NUL termination to disappear.
I found another example:
$ tr -d '[:print:]' < /etc/passwd |tr -d '\t\n' |wc -c 0
$ dash -c 'while read o p; do printf "[%s] [%s]\n" "$o" "$p"; done < /etc/passwd' |tr -d '[:print:]' |tr -d '[:space:]' |wc -c 61
bug is not fixed yet :(
Signature · 1 line
Rgrds, legion
Quoted 11 lines · Alexey Gladkov
I found another example:
$ tr -d '[:print:]' < /etc/passwd |tr -d '\t\n' |wc -c 0$ dash -c 'while read o p; do printf "[%s] [%s]\n" "$o" "$p"; done < /etc/passwd' |tr -d '[:print:]' |tr -d '[:space:]' |wc -c 61bug is not fixed yet :(
This bug is caused by an off-by-one error in the recordregion call in readcmd. It included the terminating NUL in the region which causes ifsbreakup to include the string after it for scanning.
Setting the correct length fixes the problem.
Signed-off-by Herbert Xu <[email protected]>
ChangeLog +4 -0
@@ -1,3 +1,7 @@ +2009-11-26 Herbert Xu <[email protected]> + + Fix off-by-one recordregion in readcmd. + 2009-09-28 Jim Meyering <[email protected]> don't read-uninitialized for \177 in a here-doc
src/miscbltin.c +1 -1
@@ -84,7 +84,7 @@ readcmd_handle_line(char *line, char **ap, size_t len) backup =sstrdup (line); arglist.lastp = &arglist.list; -recordregion (0 , len,0 ); +recordregion (0 , len -1 ,0 );ifsbreakup (s, &arglist); *arglist.lastp =NULL ;
Thanks,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt