[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

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



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

richard pushed a commit to branch tor-browser-91.8.0esr-11.0-1
in repository tor-browser.

commit fc945e15a1e7606f9850b769438a7b33daf95c42
Author: Peter Van der Beken <peterv@xxxxxxxxxxxxxxxx>
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 52ea1cf413a93..adee37bb24631 100644
--- a/parser/expat/lib/xmlparse.c
+++ b/parser/expat/lib/xmlparse.c
@@ -5025,11 +5025,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.
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits