[WININET] Fix FtpFindFirtFile(A/W)
Lionel Ulmer
lionel.ulmer at free.fr
Mon May 31 04:46:11 CDT 2004
Ragnarok Online's updater sets lpszSearchFile to NULL to match all files in
the FTP server's directory which crashed when we tried to match the files
found using SLWAPI's PathMatchSpec function. Moreover, I also checked the
asynchronous code and it was buggy too (it tried to strdup a NULL string) so
I fixed it too.
Lionel
Changelog:
Fix the case where lpszSearchFile is NULL in FtpFindFirstFile
--
Lionel Ulmer - http://www.bbrox.org/
-------------- next part --------------
Index: dlls/wininet/ftp.c
===================================================================
RCS file: /home/wine/wine/dlls/wininet/ftp.c,v
retrieving revision 1.42
diff -u -r1.42 ftp.c
--- dlls/wininet/ftp.c 25 May 2004 04:02:05 -0000 1.42
+++ dlls/wininet/ftp.c 31 May 2004 09:43:34 -0000
@@ -606,7 +606,7 @@
workRequest.asyncall = FTPFINDFIRSTFILEW;
workRequest.handle = hConnect;
req = &workRequest.u.FtpFindFirstFileW;
- req->lpszSearchFile = WININET_strdupW(lpszSearchFile);
+ req->lpszSearchFile = (lpszSearchFile == NULL) ? NULL : WININET_strdupW(lpszSearchFile);
req->lpFindFileData = lpFindFileData;
req->dwFlags = dwFlags;
req->dwContext= dwContext;
@@ -2659,7 +2659,7 @@
LPWININETFINDNEXTW lpwfn = NULL;
HINTERNET handle = 0;
- TRACE("(%p,%d,%p,%ld)\n", lpwfs, nSocket, lpFindFileData, dwContext);
+ TRACE("(%p,%d,%s,%p,%ld)\n", lpwfs, nSocket, debugstr_w(lpszSearchFile), lpFindFileData, dwContext);
if (FTP_ParseDirectory(lpwfs, nSocket, lpszSearchFile, &lpafp, &dwSize))
{
@@ -2878,7 +2878,8 @@
}
if(lpfp->lpszName) {
- if(PathMatchSpecW(lpfp->lpszName, lpszSearchFile)) {
+ if((lpszSearchFile == NULL) ||
+ (PathMatchSpecW(lpfp->lpszName, lpszSearchFile))) {
found = TRUE;
TRACE("Matched: %s\n", debugstr_w(lpfp->lpszName));
}
Index: dlls/wininet/internet.c
===================================================================
RCS file: /home/wine/wine/dlls/wininet/internet.c,v
retrieving revision 1.86
diff -u -r1.86 internet.c
--- dlls/wininet/internet.c 25 May 2004 04:02:05 -0000 1.86
+++ dlls/wininet/internet.c 31 May 2004 09:43:35 -0000
@@ -2556,7 +2556,8 @@
req = &workRequest.u.FtpFindFirstFileW;
FTP_FtpFindFirstFileW(workRequest.handle, req->lpszSearchFile,
req->lpFindFileData, req->dwFlags, req->dwContext);
- HeapFree(GetProcessHeap(), 0, req->lpszSearchFile);
+ if (req->lpszSearchFile != NULL)
+ HeapFree(GetProcessHeap(), 0, req->lpszSearchFile);
}
break;
More information about the wine-patches
mailing list