bug-bash
[Top][All Lists]
Advanced

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

Bash 2.05 doesn't report error for bases>2**31 on 64-bit hosts


From: Paul Eggert
Subject: Bash 2.05 doesn't report error for bases>2**31 on 64-bit hosts
Date: Sun, 29 Apr 2001 22:20:31 -0700 (PDT)

Configuration Information [Automatically generated, do not change]:
Machine: sparc
OS: solaris2.7
Compiler: cc -xarch=v9
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='sparc' 
-DCONF_OSTYPE='solaris2.7' -DCONF_MACHTYPE='sparc-sun-solaris2.7' 
-DCONF_VENDOR='sun' -DSHELL  -DHAVE_CONFIG_H  -D_LARGEFILE_SOURCE 
-D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -I.  -I.. -I../include -I../lib 
-I/tmp/prefix/include -g
uname output: SunOS sic.twinsun.com 5.7 Generic_106541-15 sun4u sparc 
SUNW,UltraSPARC-IIi-Engine
Machine Type: sparc-sun-solaris2.7

Bash Version: 2.05
Patch Level: 0
Release Status: release

Description:
        Bash 2.05 doesn't report an error for a base out of range
        (that is, less than 2 or greater than 64) if the base happens
        to be in range modulo 'int'.

Repeat-By:
        $ ((x=4294967298#10))
        $ echo $x
        2

        The output should be a diagnostic reporting an error, since
        4294967298 is out of range for a base.

Fix:

This patch also removes some redundant checks and initializations that
I found in the same routine.

2001-04-29  Paul Eggert  <address@hidden>

        * expr.c (strlong): Remove unnecessary check for NULL and "".
        Remove redundant initialization of val to zero.
        Do not convert base from long to int before checking whether it is
        out of range.

===================================================================
RCS file: expr.c,v
retrieving revision 2.5.0.2
retrieving revision 2.5.0.3
diff -pu -r2.5.0.2 -r2.5.0.3
--- expr.c      2001/04/29 07:05:42     2.5.0.2
+++ expr.c      2001/04/30 05:12:13     2.5.0.3
@@ -1029,16 +1029,13 @@ strlong (num)
   long val = 0L;
 
   s = num;
-  if (s == NULL || *s == '\0')
-    return 0L;
-
   base = 10;
   foundbase = 0;
   if (*s == '0')
     {
       s++;
 
-      if (s == NULL || *s == '\0')
+      if (*s == '\0')
        return 0L;
 
        /* Base 16? */
@@ -1052,7 +1049,6 @@ strlong (num)
       foundbase++;
     }
 
-  val = 0L;
   for (c = *s++; c; c = *s++)
     {
       if (c == '#')
@@ -1060,12 +1056,11 @@ strlong (num)
          if (foundbase)
            evalerror ("bad number");
 
-         base = (int)val;
-
          /* Illegal base specifications raise an evaluation error. */
-         if (base < 2 || base > 64)
+         if (val < 2 || val > 64)
            evalerror ("illegal arithmetic base");
 
+         base = val;
          val = 0L;
          foundbase++;
        }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]