www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1996/08/12/01:04:45

Date: Mon, 12 Aug 1996 08:00:02 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Daisuke Aoyama <jack AT st DOT rim DOT or DOT jp>
Cc: djgpp-workers AT delorie DOT com
Subject: Re: problems in bash
In-Reply-To: <199608102021.FAA03069@mercury.st.rim.or.jp>
Message-Id: <Pine.SUN.3.91.960812075715.26669A-100000@is>
Mime-Version: 1.0

On Sun, 11 Aug 1996, =?ISO-2022-JP?B?GyRCQEQ7M0JnMnAbKEI=?= /Daisuke Aoyama wrote:

> `xstat.h' says MAX_TRUE_NAME is 128 but `limits.h' says PATH_MAX is 512.
> >  strcpy(pathname, path)
> >  p = pathname + strlen(pathname) - 1;
> 
> It is rarely `path' is copied over array (and crash)
> I suggest it check `path' length before copying.

These are bugs.  Thanks for pointing them out.  Patches below.

> If coff file executed by `go32-v2' then all of exception handlers were broken
> (by `go32-v2' ?). Is it only problem under Win95 ?

``Broken''--how?  What exactly goes wrong with with the exception 
handlers?

----------------------------- cut here -------------------------------
*** posix/sys/stat/xstat.h~0	Sun Nov 12 21:51:24 1995
--- posix/sys/stat/xstat.h	Sun Aug 11 17:47:46 1996
***************
*** 32,40 ****
  #define MK_FOFF(s,o) ((int)((((unsigned long)(s)) << 4) + (unsigned short)(o)))
  #endif
  
! /* Ralph Brown's Interrupt List says this should be the length
!    of the buffer for INT 21H AX=6000H.  */
! #define MAX_TRUE_NAME   128
  
  extern unsigned short   _osmajor, _osminor;
  extern const    char  * _os_flavor;
--- 32,38 ----
  #define MK_FOFF(s,o) ((int)((((unsigned long)(s)) << 4) + (unsigned short)(o)))
  #endif
  
! #define MAX_TRUE_NAME   FILENAME_MAX
  
  extern unsigned short   _osmajor, _osminor;
  extern const    char  * _os_flavor;
*** posix/sys/stat/stat.c~5	Sat Apr 27 10:47:24 1996
--- posix/sys/stat/stat.c	Sun Aug 11 18:04:52 1996
***************
*** 819,824 ****
--- 819,825 ----
  {
    int  e = errno;
    char pathname[MAX_TRUE_NAME], *p;
+   int  pathlen;
  
    if (!path || !statbuf)
      {
***************
*** 826,838 ****
        return -1;
      }
  
!   strcpy(pathname, path);
!   p = pathname + strlen(pathname) - 1;
    /* Get rid of trailing slash.  It confuses FindFirst and also causes
       the inode-inventing mechanism think d:/path/ and d:/path are
       different, because _truename() retains one trailing slash.  But
       leave alone a trailing slash if it's a root directory, like in
       "/" or "d:/" */
    while (p > pathname && p[-1] != ':' && (*p == '/' || *p == '\\'))
      *p-- = '\0';
  
--- 827,845 ----
        return -1;
      }
  
!   if ((pathlen = strlen (path)) >= MAX_TRUE_NAME)
!     {
!       errno = ENAMETOOLONG;
!       return -1;
!     }
! 
!   memcpy(pathname, path, pathlen + 1);
    /* Get rid of trailing slash.  It confuses FindFirst and also causes
       the inode-inventing mechanism think d:/path/ and d:/path are
       different, because _truename() retains one trailing slash.  But
       leave alone a trailing slash if it's a root directory, like in
       "/" or "d:/" */
+   p = pathname + pathlen - 1;
    while (p > pathname && p[-1] != ':' && (*p == '/' || *p == '\\'))
      *p-- = '\0';
  

- Raw text -


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