bug-bash
[Top][All Lists]
Advanced

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

Bash 2.05 mishandles constants larger than 2**31 on 64-bit hosts


From: Paul Eggert
Subject: Bash 2.05 mishandles constants larger than 2**31 on 64-bit hosts
Date: Sun, 29 Apr 2001 00:10:04 -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 internally does its arithmetic with 'long', but on a host
        with 64-bit 'long' and 32-bit 'int', Bash mishandles constants
        that don't fit in 32 bits.

Repeat-By:
        $ ((x=4294967296))
        $ echo $x
        0

        The output should be '4294967296'.

Fix:

This patch assumes the previous patch I've sent in for expr.c.

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

        * expr.c (tokval): Now 'long', not 'int', to avoid losing information
        on hosts where 'long' is wider than 'int'.
        (EXPR_CONTEXT): tokval member is now 'long', not 'int'.
        (LVALUE): Remove unused type that had a tokval in it.

===================================================================
RCS file: expr.c,v
retrieving revision 2.5.0.1
retrieving revision 2.5.0.2
diff -pu -r2.5.0.1 -r2.5.0.2
--- expr.c      2001/04/13 07:08:33     2.5.0.1
+++ expr.c      2001/04/29 07:05:42     2.5.0.2
@@ -142,7 +142,7 @@ static int  curtok;         /* the current token
 static int     lasttok;        /* the previous token */
 static int     assigntok;      /* the OP in OP= */
 static char    *tokstr;        /* current token string */
-static int     tokval;         /* current token value */
+static long    tokval;         /* current token value */
 static int     noeval;         /* set to 1 if no assignment to be done */
 static procenv_t evalbuf;
 
@@ -158,16 +158,11 @@ static void       evalerror ();
 typedef struct {
   int curtok, lasttok;
   char *expression, *tp, *lasttp;
-  int tokval;
+  long tokval;
   char *tokstr;
   int noeval;
 } EXPR_CONTEXT;
 
-typedef struct {
-  char *tokstr;
-  int tokval;
-} LVALUE;
-
 /* Global var which contains the stack of expression contexts. */
 static EXPR_CONTEXT **expr_stack;
 static int expr_depth;            /* Location in the stack. */



reply via email to

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