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

When Created: 06/13/1996 09:45:04
Against DJGPP version: 2.00
By whom: eliz@is.elta.co.il
Abstract: `_is_executable' doesn't recognize .com and .bat files as executables
The `_is_executable' library function doesn't upcase the extension of
its argument filename, so it fails to recognize executable files which
are only characterized by certain extensions, like .com and .bat (as
opposed to .exe which also have a magic signature MZ at the beginning).

Solution added: 06/13/1996 09:47:08
By whom: eliz@is.elta.co.il
Apply this patch:
*** posix/sys/stat/is_exec.c~0  Sun Nov 12 23:22:48 1995
--- posix/sys/stat/is_exec.c    Sat Apr  6 13:09:48 1996
***************
*** 18,23 ****
--- 18,24 ----
  #include <libc/stubs.h>
  #include <stdio.h>
  #include <string.h>
+ #include <ctype.h>
  #include <errno.h>
  #include <dpmi.h>
  #include <go32.h>
***************
*** 182,192 ****
        && strlen(extension) <= ((extension[0]=='.') ? 4 : 3))
      {
        /* Search the list of extensions in executables[]. */
!       char tmp_buf[6];

!       tmp_buf[0] = '|';
!       strcpy(tmp_buf+1, *extension == '.' ? extension + 1 : extension);
!       strcat(tmp_buf, "|");
        if (strstr(non_executables, tmp_buf))
          return 0;
        else if (strstr(executables, tmp_buf))
--- 183,197 ----
        && strlen(extension) <= ((extension[0]=='.') ? 4 : 3))
      {
        /* Search the list of extensions in executables[]. */
!       char tmp_buf[6], *tp = tmp_buf;

!       *tp++ = '|';
!       if (*extension == '.')
!       extension++;
!       while (*extension)
!       *tp++ = toupper (*extension++);
!       *tp++ = '|';
!       *tp = '\0';
        if (strstr(non_executables, tmp_buf))
          return 0;
        else if (strstr(executables, tmp_buf))

Note added: 06/13/1996 15:47:55
By whom: terra@diku.dk (Morten Welinder)
My pet peeve: the use of toupper() on file names is likely to
cause problems if someone implements locale settings because
in that setting a file name with accented letters might lose
the accents when upcased.

Moreover, "file" and "FILE" are identical as file names while
"fil'e" and "FIL'E" are not.  (You know what I mean.)

Fixed in version 2.01 on 07/26/1996 00:25:07
By whom: dj@delorie.com



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