From bd719f4fcbfe26bb41f0be6a16de76249a32cc67 Mon Sep 17 00:00:00 2001 From: "mozilla%weilbacher.org" Date: Thu, 25 Oct 2007 20:49:37 +0000 Subject: [PATCH] [OS/2] Bug 400939: fix crash when using FireFTP with local files without extension, r=mkaply git-svn-id: svn://10.0.0.236/trunk@238163 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpcom/io/nsLocalFileOS2.cpp | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/mozilla/xpcom/io/nsLocalFileOS2.cpp b/mozilla/xpcom/io/nsLocalFileOS2.cpp index 313734aad53..ae2f7fbe9d4 100644 --- a/mozilla/xpcom/io/nsLocalFileOS2.cpp +++ b/mozilla/xpcom/io/nsLocalFileOS2.cpp @@ -2164,21 +2164,15 @@ nsLocalFile::IsExecutable(PRBool *_retval) if (pathEnd == leaf) return NS_OK; - // get the extension, including the dot, max. of 4 chars for comparison - // (copy the extension so that the original filename stays untouched) - char ext[5]; - strncpy(ext, (char*) _mbsrchr((const unsigned char*)leaf, '.'), 4); - ext[4] = '\0'; // ensure trailing nullbyte + // get the extension, including the dot + char* ext = (char*) _mbsrchr((const unsigned char*)leaf, '.'); + if (!ext) + return NS_OK; - // upper-case the extension, then see if it claims to be an executable - // WinUpper() cannot be used because it crashes with high memory. - // strupr() does not take into account non-ASCII characters but this is - // irrelevant for the possible extensions below - strupr(ext); - if (strcmp(ext, ".EXE") == 0 || - strcmp(ext, ".CMD") == 0 || - strcmp(ext, ".COM") == 0 || - strcmp(ext, ".BAT") == 0) + if (stricmp(ext, ".exe") == 0 || + stricmp(ext, ".cmd") == 0 || + stricmp(ext, ".com") == 0 || + stricmp(ext, ".bat") == 0) *_retval = PR_TRUE; return NS_OK;