[PATCH] wininet: NULL terminate url string passed to InternetCrackUrlW from InternetCrackUrlA.txt (try 3)

Nigel Liang ncliang at gmail.com
Sun Oct 14 01:58:27 CDT 2007


Hi,

InternectCrackUrlW calls strchrW which assumes a NULL-terminated string. Will
crash without NULL termination if you upload/download for long period of time.
Changed to allocate nLength+1 for the buffer and zero the entire buffer out.

-Nigel

---
 dlls/wininet/internet.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c
index 0edca74..bd6d994 100644
--- a/dlls/wininet/internet.c
+++ b/dlls/wininet/internet.c
@@ -1083,7 +1083,7 @@ BOOL WINAPI InternetCrackUrlA(LPCSTR lps
        InternetCrackUrlW should not include it                  */
   if (dwUrlLength == -1) nLength--;
 
-  lpwszUrl=HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WCHAR)*nLength);
+  lpwszUrl=HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WCHAR)*(nLength+1));
   MultiByteToWideChar(CP_ACP,0,lpszUrl,dwUrlLength,lpwszUrl,nLength);
 
   memset(&UCW,0,sizeof(UCW));
-- 
1.4.1




More information about the wine-patches mailing list