bug-bash
[Top][All Lists]
Advanced

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

bash 2.05 hang


From: Mark E .
Subject: bash 2.05 hang
Date: Sun, 19 Aug 2001 11:53:42 -0400

Hi folks,
I've had an intermittent problem with Bash 2.05 hanging with my djgpp port. I 
finally
traced the problem to lib/sh/tmpfile.c and its use of the variable filenum. 
filenum
is generated by multiplying filenum by itself and either a random number or 
another
variable like so:
      filenum *= (int)time ((time_t *)0) * dollar_dollar_pid *
                ((flags & MT_USERANDOM) ? get_random_number () : ntmpfiles++);

filenum can and does overflow given the large numbers generated. But when 
filenum
overflows to 0, Bash gets stuck in an infinite loop multiplying a number with 
zero.
My solution is to increment filenum when it does equal zero:

*** tmpfile.c.orig      Wed Feb 14 17:03:54 2001
--- tmpfile.c   Sun Aug 19 11:45:46 2001
*************** sh_mktmpname (nameroot, flags)
*** 118,123 ****
--- 118,125 ----
  
    while (1)
      {
+       if (filenum == 0)
+         ++filenum;
        filenum *= (int)time ((time_t *)0) * dollar_dollar_pid *
                ((flags & MT_USERANDOM) ? get_random_number () : ntmpfiles++);
        sprintf (filename, "%s/%s-%lu", tdir, nameroot, filenum);
*************** sh_mktmpfd (nameroot, flags, namep)
*** 153,158 ****
--- 155,162 ----
  
    do
      {
+       if (filenum == 0)
+         ++filenum;
        filenum *= (int)time ((time_t *)0) * dollar_dollar_pid *
                ((flags & MT_USERANDOM) ? get_random_number () : ntmpfiles++);
        sprintf (filename, "%s/%s-%lu", tdir, nameroot, filenum);

-- 
Mark E.: snowball3@softhome.net



reply via email to

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