[Top][All Lists]

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

Bash 2.05 test -t N mishandles large N values on 64-bit hosts

From: Paul Eggert
Subject: Bash 2.05 test -t N mishandles large N values on 64-bit hosts
Date: Mon, 30 Apr 2001 06:46:30 -0700 (PDT)

From: eggert
To: address@hidden
Subject: [50 character or so descriptive subject here (for reference)]

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' 
-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 
Machine Type: sparc-sun-solaris2.7

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

        Bash 2.05's "test -t" builtin mishandles large arguments on hosts
        where 'long' is wider than 'int'.

        $ test -t 4294967296 && echo bug

        4294967296 is not a valid terminal file descriptor, but Bash
        internally converts it to 'int', which drops the top bit and
        becomes 0, and since 0 is a terminal file descriptor the test
        improperly succeeds.


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

        * test.c (unary_test): Fail if argument to -t does not fit in 'int'.

RCS file: test.c,v
retrieving revision
retrieving revision
diff -pu -r2.5.0.2 -r2.5.0.3
--- test.c      2001/04/13 08:15:26
+++ test.c      2001/04/30 13:42:15
@@ -679,7 +679,7 @@ unary_test (op, arg)
     case 't':  /* File fd is a terminal? */
       if (legal_number (arg, &r) == 0)
        return (FALSE);
-      return (isatty ((int)r));
+      return (r == (int) r && isatty ((int) r));
     case 'n':                  /* True if arg has some length. */
       return (arg[0] != '\0');

reply via email to

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