tcsh/tcsh-6.14.00-octal.patch

33 lines
790 B
Diff
Raw Normal View History

diff -up tcsh-6.15.00/sh.set.c.octal tcsh-6.15.00/sh.set.c
--- tcsh-6.15.00/sh.set.c.octal 2006-08-24 22:56:31.000000000 +0200
+++ tcsh-6.15.00/sh.set.c 2008-09-03 12:28:10.000000000 +0200
@@ -525,6 +525,7 @@ getn(Char *cp)
{
int n;
int sign;
+ int base;
if (!cp) /* PWP: extra error checking */
stderror(ERR_NAME | ERR_BADNUM);
@@ -538,9 +539,19 @@ getn(Char *cp)
if (!Isdigit(*cp))
stderror(ERR_NAME | ERR_BADNUM);
}
+
+ if (cp[0] == '0' && cp[1])
+ base = 8;
+ else
+ base = 10;
+
n = 0;
while (Isdigit(*cp))
- n = n * 10 + *cp++ - '0';
+ {
+ if (base == 8 && *cp >= '8')
+ stderror(ERR_NAME | ERR_BADNUM);
+ n = n * base + *cp++ - '0';
+ }
if (*cp)
stderror(ERR_NAME | ERR_BADNUM);
return (sign ? -n : n);