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