www.delorie.com/djgpp/bugs/show.cgi   search  
Bug 000212

When Created: 03/15/1998 11:57:29
Against DJGPP version: 2.01
By whom: martin.stromberg@lu.erisoft.se
Abstract: Stack overwritten in djtar from alpha release 2.02 in certain conditions.
If the disk is full or directories are nested too deep, and the user
gives first one directory name (which djtar fails to create) and on
the next try gives a directory name that is longer than the first
djtar loops, making the directory name longer and longer and finally
overwrites the stack. 

Solution added: 03/15/1998 11:58:38
By whom: martin.stromberg@lu.erisoft.se
*** djlib/src/utils/djtar/djtar.org     Thu Jan  1 16:35:50 1998
--- djlib/src/utils/djtar/djtar.c       Fri Mar 13 23:23:06 1998
***************
*** 234,240 ****
--- 234,246 ----
          break;
        r = mkdir (n, 0777);
        if (r)
+       {
+         if(errno == ENOENT)
+         {
+           Fatal("Unable to create directory");
+         }
          r = change(n, "Unable to create directory", 1);
+       }
        } while (r);
        *sl = save;
      }
***************
*** 446,451 ****
--- 452,461 ----
      {
        status = change(dirname, "Duplicate directory name", 2);
        continue;
+     }
+     if (status && (errno==ENOENT))
+     {
+       Fatal("Unable to create directory");
      }
      if (status)
        status = change(dirname, "Unable to create directory", 1);

Note added: 03/15/1998 12:05:39
By whom: martin.stromberg@lu.erisoft.se
djtar can still be made to loop endlessly, but without overwriting the 
stack, on the right input in plain DOS.

Say you have a tar file containing the directories "1/aaaaaaaa" 
(eight As) and "1/aaaaaaaaa" (nine As). djtar creates the first 
directory, but fails on the second (as it is the same name in  plain 
DOS). The user is asked for a new name, he answers "aaaaaaaa" (eight 
As), which will fail. Then he answers "aaaaaaaaa" (nine As). 
Ergo loop.

Fixed in version on 04/13/1999 07:00:50
By whom: eliz@is.elta.co.il



  webmaster     delorie software   privacy  
  Copyright © 2010   by DJ Delorie     Updated Jul 2010