Re: Rergession in readcmd (commit 55c46b7)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


Alexey Gladkov <gladkov.alexey@xxxxxxxxx> wrote:
> 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]

Thanks for the report.  It's an off-by-one error causing the
NUL termination to disappear.

diff --git a/ChangeLog b/ChangeLog
index 9d397e4..13c9010 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-08-31  Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
+
+	* Fix NUL termination in readcmd.
+
 2009-08-11  Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
 
 	* Pass EV_TESTED into evalcmd.
diff --git a/src/miscbltin.c b/src/miscbltin.c
index cca0f6c..be746b2 100644
--- a/src/miscbltin.c
+++ b/src/miscbltin.c
@@ -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,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

Powered by Linux