expand: Escape minus sign in arithmetic expansion

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

 



The minus sign generated from arithmetic expansion is currently
unquoted which causes anomalies when the result is used in where
the quoting matters.

This patch fixes it by explicitly calling memtodest for the minus
sign.

Signed-off-by: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>

diff --git a/src/expand.c b/src/expand.c
index c565646..a8bc142 100644
--- a/src/expand.c
+++ b/src/expand.c
@@ -490,6 +490,11 @@ expari(int flag)
 	result = arith(p + 1);
 	popstackmark(&sm);
 
+	if (result < 0) {
+		memtodest("-", 1, flag);
+		result = -result;
+	}
+
 	len = cvtnum(result);
 
 	if (likely(!(flag & EXP_QUOTED)))
-- 
Email: Herbert Xu <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



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux