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