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