delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1998/03/16/06:32:45

Date: Mon, 16 Mar 1998 13:30:15 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Martin Stromberg <Martin DOT Stromberg AT lu DOT erisoft DOT se>
cc: djgpp-workers AT delorie DOT com, DJ Delorie <dj AT delorie DOT com>
Subject: Re: Where to get the latest sources for djtar
In-Reply-To: <199803151753.SAA03418@propus.lu.erisoft.se>
Message-ID: <Pine.SUN.3.91.980316132944.13570E-100000@is>
MIME-Version: 1.0

On Sun, 15 Mar 1998, Martin Stromberg wrote:

> > Testing for ENOENT is likely to backfire, as DOS makes libc functions 
> > generate ENOENT in too many cases.
> 
> Well, if djtar fails to create a directory because of too deep directory
> nesting, it shouldn't give up, should it? Perhaps there are more files to
> be extracted later in the archive higher up in the directory structure.

Sorry, I lost you here.  Didn't your patch *introduce* the possibility
of `djtar' giving up?

What I meant was that ENOENT is not a reliable symptom for any smart
fault-tolerancy here.  Way too many different causes will cause
ENOENT, and it is not right IMHO for `djtar' to bail out the first
time it couldn't create a directory.  One of `djtar's main purposes is
to make sure none of the files in the archive are lost due to DOS
deficiencies.

> Note that the user don't know why it couldn't create the directory, so
> he first tries to give one name and then when that fails another longer
> one consisting of the first name and a "2" (in my case it was "elf" and
> then "elf2"), which makes djtar overwrite the stack (in my case it was
> "elf2222222222222222222222222222222222...222").
> Later I found out that if the disk is full, the same behaviour is shown.

The problem is that `djtar' automatically applied change rules for
directory names without testing whether they have ever worked before.
This made it loop endlessly, eventually overwriting the stack.  Please
try the patch below and tell me if it helps.

> +         if(errno == ENOENT
> +         && (is_disk_full() || too_deep_dirs())
> +         {
> +           Fatal("Unable to create directory");
> +         }

I think testing for a full disk is too expensive, and also doesn't
cover all the cases (e.g., a write-protected floppy that isn't full).

*** src/utils/djtar/djtar.c~0	Thu Jan  1 23:35:50 1998
--- src/utils/djtar/djtar.c	Mon Mar 16 12:17:26 1998
*************** change(char *fname, const char *problem,
*** 138,144 ****
    char *pos;
  
    for (ch=change_root; ch; ch = ch->next)
!     if ((strncmp(fname, ch->old, strlen(ch->old)) == 0) && ch->isdir)
      {
        if (ch->isdir == 2)
        {
--- 138,146 ----
    char *pos;
  
    for (ch=change_root; ch; ch = ch->next)
!     if ((strncmp(fname, ch->old, strlen(ch->old)) == 0) && ch->isdir
! 	/* Don't use change rules which failed to work before.  */
! 	&& access(ch->new, D_OK) == 0)
      {
        if (ch->isdir == 2)
        {


- Raw text -


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