⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 281019 in webkit


Ignore:
Timestamp:
Aug 13, 2021, 8:38:40 AM (5 years ago)
Author:
Alan Coon
Message:

Cherry-pick r281008. rdar://problem/81901037

Fix bounds checks for WhitespaceCache string lengths
https://bugs.webkit.org/show_bug.cgi?id=229066
<rdar://81850871>

Reviewed by Simon Fraser.

When the whitespace string length is maximumWhitespaceStringLength,
we read from and write to one element past the end of m_codes and
m_indexes. Since we don't need to store codes and indexes for zero
length strings, subtract one from the index we use.

  • html/parser/HTMLConstructionSite.cpp: (WebCore::WhitespaceCache::lookup):
  • html/parser/HTMLConstructionSite.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281008 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Location:
branches/safari-612.1.28-branch/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-612.1.28-branch/Source/WebCore/ChangeLog

    r280958 r281019  
     12021-08-13  Alan Coon  <alancoon@apple.com>
     2
     3        Cherry-pick r281008. rdar://problem/81901037
     4
     5    Fix bounds checks for WhitespaceCache string lengths
     6    https://bugs.webkit.org/show_bug.cgi?id=229066
     7    <rdar://81850871>
     8   
     9    Reviewed by Simon Fraser.
     10   
     11    When the whitespace string length is maximumWhitespaceStringLength,
     12    we read from and write to one element past the end of m_codes and
     13    m_indexes. Since we don't need to store codes and indexes for zero
     14    length strings, subtract one from the index we use.
     15   
     16    * html/parser/HTMLConstructionSite.cpp:
     17    (WebCore::WhitespaceCache::lookup):
     18    * html/parser/HTMLConstructionSite.h:
     19   
     20   
     21    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281008 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     22
     23    2021-08-12  Cameron McCormack  <heycam@apple.com>
     24
     25            Fix bounds checks for WhitespaceCache string lengths
     26            https://bugs.webkit.org/show_bug.cgi?id=229066
     27            <rdar://81850871>
     28
     29            Reviewed by Simon Fraser.
     30
     31            When the whitespace string length is maximumWhitespaceStringLength,
     32            we read from and write to one element past the end of m_codes and
     33            m_indexes. Since we don't need to store codes and indexes for zero
     34            length strings, subtract one from the index we use.
     35
     36            * html/parser/HTMLConstructionSite.cpp:
     37            (WebCore::WhitespaceCache::lookup):
     38            * html/parser/HTMLConstructionSite.h:
     39
    1402021-08-12  Youenn Fablet  <youenn@apple.com>
    241
  • branches/safari-612.1.28-branch/Source/WebCore/html/parser/HTMLConstructionSite.cpp

    r280773 r281019  
    892892        return AtomString();
    893893
    894     if (m_codes[length] == code) {
    895         ASSERT(m_atoms[m_indexes[length]] == string);
    896         return m_atoms[m_indexes[length]];
     894    size_t lengthIndex = length - 1;
     895    if (m_codes[lengthIndex] == code) {
     896        ASSERT(m_atoms[m_indexes[lengthIndex]] == string);
     897        return m_atoms[m_indexes[lengthIndex]];
    897898    }
    898899
     
    900901        return AtomString(string);
    901902
    902     if (m_codes[length]) {
     903    if (m_codes[lengthIndex]) {
    903904        AtomString whitespaceAtom(string);
    904         m_codes[length] = code;
    905         m_atoms[m_indexes[length]] = whitespaceAtom;
     905        m_codes[lengthIndex] = code;
     906        m_atoms[m_indexes[lengthIndex]] = whitespaceAtom;
    906907        return whitespaceAtom;
    907908    }
    908909
    909910    AtomString whitespaceAtom(string);
    910     m_codes[length] = code;
    911     m_indexes[length] = m_atoms.size();
     911    m_codes[lengthIndex] = code;
     912    m_indexes[lengthIndex] = m_atoms.size();
    912913    m_atoms.append(whitespaceAtom);
    913914    return whitespaceAtom;
  • branches/safari-612.1.28-branch/Source/WebCore/html/parser/HTMLConstructionSite.h

    r280772 r281019  
    239239
    240240    // Parallel arrays storing a 64 bit code and an index into m_atoms for the
    241     // most recently atomized whitespace-only string of a given length.
     241    // most recently atomized whitespace-only string of a given length. The
     242    // indices into these two arrays are the string length minus 1, so the code
     243    // for a whitespace-only string of length 2 is stored at m_codes[1], etc.
    242244    uint64_t m_codes[maximumCachedStringLength] { 0 };
    243245    uint8_t m_indexes[maximumCachedStringLength] { 0 };
Note: See TracChangeset for help on using the changeset viewer.