From e2c0694901638c803aaa88d5c49164e8e4802f18 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Tue, 18 Nov 2014 07:05:05 +0100 Subject: [PATCH] comctl32: Fix incorrect usage of CompareString in SYSLINK_ParseText. --- dlls/comctl32/syslink.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/dlls/comctl32/syslink.c b/dlls/comctl32/syslink.c index a5ba3dd422d..eeb46b98053 100644 --- a/dlls/comctl32/syslink.c +++ b/dlls/comctl32/syslink.c @@ -184,6 +184,26 @@ static VOID SYSLINK_ClearDoc (SYSLINK_INFO *infoPtr) } /*********************************************************************** + * 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 * Parses the window text string and creates a document. Returns the * number of document items created. @@ -203,7 +223,7 @@ static UINT SYSLINK_ParseText (SYSLINK_INFO *infoPtr, LPCWSTR Text) { if(*current == '<') { - if(!StrCmpNIW(current, SL_LINKOPEN, 2) && (CurrentType == slText)) + if(!SYSLINK_StrCmpNIW(current, SL_LINKOPEN, 2) && (CurrentType == slText)) { BOOL ValidParam = FALSE, ValidLink = FALSE; @@ -231,14 +251,14 @@ static UINT SYSLINK_ParseText (SYSLINK_INFO *infoPtr, LPCWSTR Text) CheckParameter: /* compare the current position with all known parameters */ - if(!StrCmpNIW(tmp, SL_HREF, 6)) + if(!SYSLINK_StrCmpNIW(tmp, SL_HREF, 6)) { taglen += 6; ValidParam = TRUE; CurrentParameter = &lpUrl; CurrentParameterLen = &lenUrl; } - else if(!StrCmpNIW(tmp, SL_ID, 4)) + else if(!SYSLINK_StrCmpNIW(tmp, SL_ID, 4)) { taglen += 4; 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 tag opened, first add the previous text, if present */ if(textstart != NULL && textlen > 0 && firsttag > textstart) -- 2.11.4.GIT