delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/08/25/08:25:31

Date: Wed, 25 Aug 1999 12:21:01 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Laurynas Biveinis <lauras AT softhome DOT net>
cc: DJGPP Workers <djgpp-workers AT delorie DOT com>
Subject: Re: symlink() bug & fix
In-Reply-To: <37C01A4C.AC7346AF@softhome.net>
Message-ID: <Pine.SUN.3.91.990825121245.2834F-100000@is>
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Sun, 22 Aug 1999, Laurynas Biveinis wrote:

> if (strnicmp (src_abs, dest_abs, src_base - src_abs))
> 
> This test fails if e.g. source is "c:\command.com"
> and destination is "c:\dir\command.com", because 
> src_base - src_abs gives 3, so only "c:\" from both
> strings are compared, which gives incorrect result.

Thanks for spotting this.  Here's the patch I checked in today:

*** src/libc/posix/unistd/symlink.c~0	Tue Oct 28 21:22:54 1997
--- src/libc/posix/unistd/symlink.c	Tue Aug 24 15:47:42 1999
*************** symlink (const char *source, const char 
*** 74,80 ****
    dest_base = tail (dest_abs);
  
    /* DJGPP symlinks must be in the same directory.  */
!   if (strnicmp (src_abs, dest_abs, src_base - src_abs))
      {
        errno = EXDEV;
        return -1;
--- 74,81 ----
    dest_base = tail (dest_abs);
  
    /* DJGPP symlinks must be in the same directory.  */
!   if (src_base - src_abs != dest_base - dest_abs
!       || strnicmp (src_abs, dest_abs, src_base - src_abs))
      {
        errno = EXDEV;
        return -1;


- Raw text -


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