From 438b051bb23ea1c02ab5a8e515cdbab93fc483bc Mon Sep 17 00:00:00 2001 From: "dougt%netscape.com" Date: Sat, 29 Jul 2000 08:13:39 +0000 Subject: [PATCH] 46044 fixes ABR. submitted by jband@netscape.com. git-svn-id: svn://10.0.0.236/trunk@75154 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpcom/io/nsLocalFileWin.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/mozilla/xpcom/io/nsLocalFileWin.cpp b/mozilla/xpcom/io/nsLocalFileWin.cpp index 6067037aa51..74b88c28d9f 100644 --- a/mozilla/xpcom/io/nsLocalFileWin.cpp +++ b/mozilla/xpcom/io/nsLocalFileWin.cpp @@ -357,8 +357,14 @@ nsLocalFile::ResolvePath(const char* workingPath, PRBool resolveTerminal, char** // we have a drive letter and a colon (eg 'c:' // this is resolve already - *resolvedPath = (char*) nsMemory::Clone( filePath, strlen(filePath)+2 ); - strcat(*resolvedPath, "\\"); + int filePathLen = strlen(filePath); + char* rp = (char*) nsMemory::Alloc( filePathLen + 2 ); + if (!rp) + return NS_ERROR_OUT_OF_MEMORY; + memcpy( rp, filePath, filePathLen ); + rp[filePathLen] = '\\'; + rp[filePathLen+1] = 0; + *resolvedPath = rp; nsMemory::Free(filePath); return NS_OK; @@ -545,7 +551,7 @@ nsLocalFile::ResolveAndStat(PRBool resolveTerminal) int pathLen = strlen(workingFilePath); const char* leaf = workingFilePath + pathLen - 4; - if ( (strcmp(leaf, ".lnk") != 0)) + if (pathLen >= 4 && (strcmp(leaf, ".lnk") != 0)) { mDirty = PR_FALSE; return NS_OK; @@ -613,11 +619,16 @@ nsLocalFile::InitWithPath(const char *filePath) if ( (filePath[2] == 0) && (filePath[1] == ':') ) { - nativeFilePath = (char*) nsMemory::Clone( filePath, 4 ); // C : // + nativeFilePath = (char*) nsMemory::Alloc( 4 ); + if (!nativeFilePath) + return NS_ERROR_OUT_OF_MEMORY; + nativeFilePath[0] = filePath[0]; + nativeFilePath[1] = ':'; nativeFilePath[2] = '\\'; + nativeFilePath[3] = 0; } - + // XXX is this an 'else'? Otherwise 'nativeFilePath' could leak. if ( ( (filePath[1] == ':') && (strchr(filePath, '/') == 0) ) || // normal windows path ( (filePath[0] == '\\') && (filePath[1] == '\\') ) ) // netwerk path {