[tbb-commits] [tor-browser] 100/311: Bug 1754724 - Clear up some more computations in expat code. r=farre, a=tritter

gitolite role git at cupani.torproject.org
Tue Apr 26 15:28:20 UTC 2022


This is an automated email from the git hooks/post-receive script.

pierov pushed a commit to branch geckoview-99.0.1-11.0-1
in repository tor-browser.

commit a1e59b20df897cca0c7d1939e247f5090981a173
Author: Peter Van der Beken <peterv at propagandism.org>
AuthorDate: Wed Mar 2 22:22:08 2022 +0000

    Bug 1754724 - Clear up some more computations in expat code. r=farre, a=tritter
    
    Depends on D140165
    
    Differential Revision: https://phabricator.services.mozilla.com/D140166
---
 parser/expat/lib/xmlparse.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/parser/expat/lib/xmlparse.c b/parser/expat/lib/xmlparse.c
index 4584a9a1ee259..03c4dd7ff05de 100644
--- a/parser/expat/lib/xmlparse.c
+++ b/parser/expat/lib/xmlparse.c
@@ -5037,11 +5037,26 @@ doProlog(XML_Parser parser,
     case XML_ROLE_GROUP_OPEN:
       if (prologState.level >= groupSize) {
         if (groupSize) {
+          /* Detect and prevent integer overflow */
+          if (parser->m_groupSize > (unsigned int)(-1) / 2u) {
+            return XML_ERROR_NO_MEMORY;
+          }
+
           char *temp = (char *)REALLOC(groupConnector, groupSize *= 2);
           if (temp == NULL)
             return XML_ERROR_NO_MEMORY;
           groupConnector = temp;
           if (dtd->scaffIndex) {
+            /* Detect and prevent integer overflow.
+             * The preprocessor guard addresses the "always false" warning
+             * from -Wtype-limits on platforms where
+             * sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */
+#if UINT_MAX >= SIZE_MAX
+            if (parser->m_groupSize > (size_t)(-1) / sizeof(int)) {
+              return XML_ERROR_NO_MEMORY;
+            }
+#endif
+
             int *temp = (int *)REALLOC(dtd->scaffIndex,
                           groupSize * sizeof(int));
             if (temp == NULL)

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the tbb-commits mailing list