Sebastian Lackner : shlwapi: Fix invalid usage of CompareString in StrStr functions.
Alexandre Julliard
julliard at wine.codeweavers.com
Mon Nov 17 07:43:45 CST 2014
Module: wine
Branch: master
Commit: 5aec09e4d1c92e099edff03ac786895b3896e233
URL: http://source.winehq.org/git/wine.git/?a=commit;h=5aec09e4d1c92e099edff03ac786895b3896e233
Author: Sebastian Lackner <sebastian at fds-team.de>
Date: Mon Nov 17 09:11:08 2014 +0100
shlwapi: Fix invalid usage of CompareString in StrStr functions.
---
dlls/shlwapi/string.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/dlls/shlwapi/string.c b/dlls/shlwapi/string.c
index b4b5b8a..eaaaf3b 100644
--- a/dlls/shlwapi/string.c
+++ b/dlls/shlwapi/string.c
@@ -364,7 +364,7 @@ int WINAPI StrCmpIW(LPCWSTR lpszStr, LPCWSTR lpszComp)
* PARAMS
* lpszStr [I] First string to compare
* lpszComp [I] Second string to compare
- * iLen [I] Maximum number of chars to compare.
+ * iLen [I] Number of chars to compare
*
* RETURNS
* An integer less than, equal to or greater than 0, indicating that
@@ -395,7 +395,7 @@ INT WINAPI StrCmpNW(LPCWSTR lpszStr, LPCWSTR lpszComp, INT iLen)
* PARAMS
* lpszStr [I] First string to compare
* lpszComp [I] Second string to compare
- * iLen [I] Maximum number of chars to compare.
+ * iLen [I] Number of chars to compare
*
* RETURNS
* An integer less than, equal to or greater than 0, indicating that
@@ -521,13 +521,15 @@ static LPSTR SHLWAPI_StrStrHelperA(LPCSTR lpszStr, LPCSTR lpszSearch,
INT (WINAPI *pStrCmpFn)(LPCSTR,LPCSTR,INT))
{
size_t iLen;
+ LPCSTR end;
if (!lpszStr || !lpszSearch || !*lpszSearch)
return NULL;
iLen = strlen(lpszSearch);
+ end = lpszStr + strlen(lpszStr);
- while (*lpszStr)
+ while (lpszStr + iLen <= end)
{
if (!pStrCmpFn(lpszStr, lpszSearch, iLen))
return (LPSTR)lpszStr;
@@ -670,6 +672,7 @@ LPSTR WINAPI StrStrIA(LPCSTR lpszStr, LPCSTR lpszSearch)
LPWSTR WINAPI StrStrIW(LPCWSTR lpszStr, LPCWSTR lpszSearch)
{
int iLen;
+ LPCWSTR end;
TRACE("(%s,%s)\n", debugstr_w(lpszStr), debugstr_w(lpszSearch));
@@ -677,8 +680,9 @@ LPWSTR WINAPI StrStrIW(LPCWSTR lpszStr, LPCWSTR lpszSearch)
return NULL;
iLen = strlenW(lpszSearch);
+ end = lpszStr + strlenW(lpszStr);
- while (*lpszStr)
+ while (lpszStr + iLen <= end)
{
if (!StrCmpNIW(lpszStr, lpszSearch, iLen))
return (LPWSTR)lpszStr;
More information about the wine-cvs
mailing list