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