[PATCH] wininet: Substitute strchrW with memchrW in InternetCrackUrlW.txt
Nigel Liang
ncliang at gmail.com
Tue Oct 16 23:49:48 CDT 2007
Hi,
strchrW assumes a NULL-terminated string. May crash if terminating character is
not found. memchrW is better because you can specify the maximum number of
bytes to search.
-Nigel
---
dlls/wininet/internet.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c
index 4c1472c..eb2b9e2 100644
--- a/dlls/wininet/internet.c
+++ b/dlls/wininet/internet.c
@@ -1243,7 +1243,7 @@ BOOL WINAPI InternetCrackUrlW(LPCWSTR lp
const WCHAR lpszSeparators[3]={';','?',0};
const WCHAR lpszSlash[2]={'/',0};
- TRACE("(%s %u %x %p)\n", debugstr_w(lpszUrl), dwUrlLength, dwFlags, lpUC);
+ TRACE("(%s %u %x %p)\n", debugstr_wn(lpszUrl, dwUrlLength), dwUrlLength, dwFlags, lpUC);
if (!lpszUrl_orig || !*lpszUrl_orig || !lpUC)
{
@@ -1328,7 +1328,8 @@ BOOL WINAPI InternetCrackUrlW(LPCWSTR lp
/* [<user>[<:password>]@]<host>[:<port>] */
/* First find the user and password if they exist */
- lpszHost = strchrW(lpszcp, '@');
+ lpszHost = memchrW(lpszcp, '@', sizeof(WCHAR) *
+ (dwUrlLength-(lpszNetLoc-lpszUrl)));
if (lpszHost == NULL || lpszHost > lpszNetLoc)
{
/* username and password not specified. */
@@ -1451,7 +1452,8 @@ BOOL WINAPI InternetCrackUrlW(LPCWSTR lp
/* Leave the parameter list in lpszUrlPath. Strip off any trailing
* newlines if necessary.
*/
- LPWSTR lpsznewline = strchrW(lpszcp, '\n');
+ LPWSTR lpsznewline = memchrW(lpszcp, '\n', sizeof(WCHAR) *
+ (dwUrlLength-(lpszcp-lpszUrl)));
if (lpsznewline != NULL)
len = lpsznewline - lpszcp;
else
--
1.4.1
More information about the wine-patches
mailing list