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