about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2008-05-14 10:48:26 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2008-05-14 10:48:26 +0000
commitb86c191af5689229c398ecdc0684f3ccbf8a108d (patch)
tree2fa298bc06a0a99cb1970dbe804a734b964702b1
parent547adf2021e2e57e421d27e5620170a8751d4274 (diff)
downloadzsh-b86c191af5689229c398ecdc0684f3ccbf8a108d.tar.gz
zsh-b86c191af5689229c398ecdc0684f3ccbf8a108d.tar.xz
zsh-b86c191af5689229c398ecdc0684f3ccbf8a108d.zip
25025: check radix for integer constants is between 2 and 36 inclusive
-rw-r--r--ChangeLog6
-rw-r--r--Doc/Zsh/builtins.yo2
-rw-r--r--Src/builtin.c4
-rw-r--r--Src/math.c4
-rw-r--r--Src/utils.c2
5 files changed, 16 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 43878d90a..3d833a318 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-05-14  Peter Stephenson  <pws@csr.com>
+
+	* 25025: Doc/Zsh/builtins.yo, Src/builtin.c, Src/math.c,
+	Src/utils.c: more checks to ensure radix for arithmetic
+	constants is between 2 and 36 inclusive.
+
 2008-05-13  Peter Stephenson  <pws@csr.com>
 
 	* 25018: Omari Norman: Completion/Unix/Command/{_awk,_cut,_join}:
diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo
index dad180180..68f614508 100644
--- a/Doc/Zsh/builtins.yo
+++ b/Doc/Zsh/builtins.yo
@@ -1555,7 +1555,7 @@ for non-special parameters.
 item(tt(-i))(
 Use an internal integer representation.  If var(n) is nonzero it
 defines the output arithmetic base, otherwise it is determined by the
-first assignment.
+first assignment.  Bases from 2 to 36 inclusive are allowed.
 )
 item(tt(-E))(
 Use an internal double-precision floating point representation.  On output
diff --git a/Src/builtin.c b/Src/builtin.c
index f11d5aa51..99eef93aa 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -1744,6 +1744,10 @@ typeset_setbase(const char *name, Param pm, Options ops, int on, int always)
 		zwarnnam(name, "bad precision value: %s", arg);
 	    return 1;
 	}
+	if (pm->base < 2 || pm->base > 36) {
+	    zwarnnam(name, "invalid base: %d", pm->base);
+	    return 1;
+	}
     } else if (always)
 	pm->base = 0;
 
diff --git a/Src/math.c b/Src/math.c
index e1cde5f03..3374efddd 100644
--- a/Src/math.c
+++ b/Src/math.c
@@ -460,6 +460,10 @@ zzlex(void)
 		}
 		if(*ptr != ']')
 			goto bofs;
+		if (outputradix < 2 || outputradix > 36) {
+		    zerr("invalid base: %d", outputradix);
+		    return EOI;
+		}
 		ptr++;
 		break;
 	    }
diff --git a/Src/utils.c b/Src/utils.c
index d3319f0a9..4992680fe 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -1834,7 +1834,7 @@ zstrtol(const char *s, char **t, int base)
 	    base = 8;
     }
     inp = s;
-    if (base > 36) {
+    if (base < 2 || base > 36) {
 	zerr("invalid base: %d", base);
 	return (zlong)0;
     } else if (base <= 10)