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