Changeset 204502 in webkit


Ignore:
Timestamp:
Aug 16, 2016 2:43:04 AM (8 years ago)
Author:
pvollan@apple.com
Message:

[Win] Hardening of getLinkedFonts function.
https://bugs.webkit.org/show_bug.cgi?id=160850

The SUCCEEDED macro should only be used for functions returning a HRESULT type.
Also, make sure a string array index will not exceed the string length.

  • platform/graphics/win/FontCacheWin.cpp:

(WebCore::getLinkedFonts):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r204501 r204502  
     12016-08-16  Per Arne Vollan  <pvollan@apple.com>
     2
     3        [Win] Hardening of getLinkedFonts function.
     4        https://bugs.webkit.org/show_bug.cgi?id=160850
     5
     6        The SUCCEEDED macro should only be used for functions returning a HRESULT type.
     7        Also, make sure a string array index will not exceed the string length.
     8
     9        * platform/graphics/win/FontCacheWin.cpp:
     10        (WebCore::getLinkedFonts):
     11
    1122016-08-16  Alex Christensen  <achristensen@webkit.org>
    213
  • trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp

    r201979 r204502  
    117117
    118118    WCHAR* linkedFonts = reinterpret_cast<WCHAR*>(malloc(linkedFontsBufferSize));
    119     if (SUCCEEDED(RegQueryValueEx(fontLinkKey, family.charactersWithNullTermination().data(), 0, NULL, reinterpret_cast<BYTE*>(linkedFonts), &linkedFontsBufferSize))) {
     119    if (::RegQueryValueEx(fontLinkKey, family.charactersWithNullTermination().data(), 0, nullptr, reinterpret_cast<BYTE*>(linkedFonts), &linkedFontsBufferSize) == ERROR_SUCCESS) {
    120120        unsigned i = 0;
    121121        unsigned length = linkedFontsBufferSize / sizeof(*linkedFonts);
     
    123123            while (i < length && linkedFonts[i] != ',')
    124124                i++;
     125            // Break if we did not find a comma.
     126            if (i == length)
     127                break;
    125128            i++;
    126129            unsigned j = i;
Note: See TracChangeset for help on using the changeset viewer.