X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-workers-bounces using -f From: "Juan Manuel Guerrero" Organization: Darmstadt University of Technology To: djgpp-workers AT delorie DOT com Date: Wed, 20 Feb 2002 11:42:39 +0100 Subject: SIGSEGV and strlwr/strupr X-mailer: Pegasus Mail for Windows (v2.54DE) Message-ID: <271CA283011@HRZ1.hrz.tu-darmstadt.de> Reply-To: djgpp-workers AT delorie DOT com The following code is part of the command-line parsing code of bison 1.32/33. /* Under plain DOS, there is no difference on the case. This can be troublesome when looking for `.tab' etc. */ #ifdef MSDOS # if defined (__DJGPP__) /* Windows 9X and successors are case sensitive. */ # define AS_FILE_NAME(File) ((pathconf ((File), _PC_NAME_MAX) > 12) ? (File) : (strlwr (File), (File))) # else # define AS_FILE_NAME(File) (strlwr (File), (File)) # endif #else # define AS_FILE_NAME(File) (File) #endif It works OK as long as some kind of windows is used as dpmi server. As soon as cwsdpmi is used, bison dies with an error=0004. The reason is that strlwr() does not check if the passed pointer is a NULL pointer. In this case the while-loop derefences a NULL pointer producing the SIGSEGV. This is the reason why for certain combinations of command-line options bison 1.32/33 breaks on plain dos. The small patch below will fix this for strlwr and strupr (suffers from the same bug). Regards, Guerrero, Juan Manuel diff -auprNU3 djgpp.orig/src/libc/compat/string/strlwr.c djgpp/src/libc/compat/string/strlwr.c --- djgpp.orig/src/libc/compat/string/strlwr.c Thu Jun 3 19:27:34 1999 +++ djgpp/src/libc/compat/string/strlwr.c Wed Feb 20 11:17:34 2002 @@ -7,6 +7,8 @@ char * strlwr(char *_s) { char *rv = _s; + if (!_s) + return rv; while (*_s) { *_s = tolower((unsigned char)*_s); diff -auprNU3 djgpp.orig/src/libc/compat/string/strlwr.txh djgpp/src/libc/compat/string/strlwr.txh --- djgpp.orig/src/libc/compat/string/strlwr.txh Sun Sep 27 17:21:10 1998 +++ djgpp/src/libc/compat/string/strlwr.txh Wed Feb 20 10:15:38 2002 @@ -14,7 +14,7 @@ case letters. @subheading Return Value -The string. +@var{string} @subheading Portability diff -auprNU3 djgpp.orig/src/libc/compat/string/strupr.c djgpp/src/libc/compat/string/strupr.c --- djgpp.orig/src/libc/compat/string/strupr.c Thu Jun 3 19:27:34 1999 +++ djgpp/src/libc/compat/string/strupr.c Wed Feb 20 11:17:34 2002 @@ -7,6 +7,8 @@ char * strupr(char *_s) { char *rv = _s; + if (!_s) + return rv; while (*_s) { *_s = toupper((unsigned char)*_s);