comctl32: Fix incorrect usage of CompareString in SYSLINK_ParseText.

This commit is contained in:
Sebastian Lackner 2014-11-18 07:05:05 +01:00 committed by Alexandre Julliard
parent d5ba7451a3
commit e2c0694901
1 changed files with 24 additions and 4 deletions

View File

@ -183,6 +183,26 @@ static VOID SYSLINK_ClearDoc (SYSLINK_INFO *infoPtr)
infoPtr->Items = NULL; infoPtr->Items = NULL;
} }
/***********************************************************************
* SYSLINK_StrCmpNIW
* Wrapper for StrCmpNIW to ensure 'len' is not too big.
*/
static INT SYSLINK_StrCmpNIW (LPCWSTR str, LPCWSTR comp, INT len)
{
INT i;
for(i = 0; i < len; i++)
{
if(!str[i])
{
len = i + 1;
break;
}
}
return StrCmpNIW(str, comp, len);
}
/*********************************************************************** /***********************************************************************
* SYSLINK_ParseText * SYSLINK_ParseText
* Parses the window text string and creates a document. Returns the * Parses the window text string and creates a document. Returns the
@ -203,7 +223,7 @@ static UINT SYSLINK_ParseText (SYSLINK_INFO *infoPtr, LPCWSTR Text)
{ {
if(*current == '<') if(*current == '<')
{ {
if(!StrCmpNIW(current, SL_LINKOPEN, 2) && (CurrentType == slText)) if(!SYSLINK_StrCmpNIW(current, SL_LINKOPEN, 2) && (CurrentType == slText))
{ {
BOOL ValidParam = FALSE, ValidLink = FALSE; BOOL ValidParam = FALSE, ValidLink = FALSE;
@ -231,14 +251,14 @@ static UINT SYSLINK_ParseText (SYSLINK_INFO *infoPtr, LPCWSTR Text)
CheckParameter: CheckParameter:
/* compare the current position with all known parameters */ /* compare the current position with all known parameters */
if(!StrCmpNIW(tmp, SL_HREF, 6)) if(!SYSLINK_StrCmpNIW(tmp, SL_HREF, 6))
{ {
taglen += 6; taglen += 6;
ValidParam = TRUE; ValidParam = TRUE;
CurrentParameter = &lpUrl; CurrentParameter = &lpUrl;
CurrentParameterLen = &lenUrl; CurrentParameterLen = &lenUrl;
} }
else if(!StrCmpNIW(tmp, SL_ID, 4)) else if(!SYSLINK_StrCmpNIW(tmp, SL_ID, 4))
{ {
taglen += 4; taglen += 4;
ValidParam = TRUE; ValidParam = TRUE;
@ -312,7 +332,7 @@ CheckParameter:
} }
} }
} }
else if(!StrCmpNIW(current, SL_LINKCLOSE, 4) && (CurrentType == slLink) && firsttag) else if(!SYSLINK_StrCmpNIW(current, SL_LINKCLOSE, 4) && (CurrentType == slLink) && firsttag)
{ {
/* there's a <a...> tag opened, first add the previous text, if present */ /* there's a <a...> tag opened, first add the previous text, if present */
if(textstart != NULL && textlen > 0 && firsttag > textstart) if(textstart != NULL && textlen > 0 && firsttag > textstart)