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