7a48c4
diff -up firefox-91.7.0/parser/expat/lib/xmlparse.c.expat-CVE-2022-25315 firefox-91.7.0/parser/expat/lib/xmlparse.c
7a48c4
--- firefox-91.7.0/parser/expat/lib/xmlparse.c.expat-CVE-2022-25315	2022-03-02 18:17:50.966583254 +0100
7a48c4
+++ firefox-91.7.0/parser/expat/lib/xmlparse.c	2022-03-02 18:19:27.636924735 +0100
7a48c4
@@ -2479,6 +2479,7 @@ storeRawNames(XML_Parser parser)
7a48c4
   while (tag) {
7a48c4
     int bufSize;
7a48c4
     int nameLen = sizeof(XML_Char) * (tag->name.strLen + 1);
7a48c4
+    size_t rawNameLen;
7a48c4
     char *rawNameBuf = tag->buf + nameLen;
7a48c4
     /* Stop if already stored.  Since tagStack is a stack, we can stop
7a48c4
        at the first entry that has already been copied; everything
7a48c4
@@ -2490,7 +2491,11 @@ storeRawNames(XML_Parser parser)
7a48c4
     /* For re-use purposes we need to ensure that the
7a48c4
        size of tag->buf is a multiple of sizeof(XML_Char).
7a48c4
     */
7a48c4
-    bufSize = nameLen + ROUND_UP(tag->rawNameLength, sizeof(XML_Char));
7a48c4
+    rawNameLen = ROUND_UP(tag->rawNameLength, sizeof(XML_Char));
7a48c4
+    /* Detect and prevent integer overflow. */
7a48c4
+    if (rawNameLen > (size_t)INT_MAX - nameLen)
7a48c4
+      return XML_FALSE;
7a48c4
+    bufSize = nameLen + (int)rawNameLen;
7a48c4
     if (bufSize > tag->bufEnd - tag->buf) {
7a48c4
       char *temp = (char *)REALLOC(tag->buf, bufSize);
7a48c4
       if (temp == NULL)