Merge branch 'qualys-2020'
[exim.git] / src / src / receive.c
index 3a3f73e87319013fffae74477101530359f81fcc..2223d46452fc43184f3f9e36e0c27c6f2e587a78 100644 (file)
@@ -486,18 +486,18 @@ Returns:      nothing
 void
 receive_add_recipient(uschar *recipient, int pno)
 {
-/* XXX This is a math limit; we should consider a performance/sanity limit too. */
-const int safe_recipients_limit = INT_MAX / sizeof(recipient_item) - 1;
-
 if (recipients_count >= recipients_list_max)
   {
   recipient_item *oldlist = recipients_list;
   int oldmax = recipients_list_max;
-  recipients_list_max = recipients_list_max ? 2*recipients_list_max : 50;
-  if ((recipients_list_max >= safe_recipients_limit) || (recipients_list_max < 0))
+
+  const int safe_recipients_limit = INT_MAX / 2 / sizeof(recipient_item);
+  if (recipients_list_max < 0 || recipients_list_max >= safe_recipients_limit)
     {
-    log_write(0, LOG_MAIN|LOG_PANIC, "Too many recipients needed: %d not satisfiable", recipients_list_max);
+    log_write(0, LOG_MAIN|LOG_PANIC_DIE, "Too many recipients: %d", recipients_list_max);
     }
+
+  recipients_list_max = recipients_list_max ? 2*recipients_list_max : 50;
   recipients_list = store_get(recipients_list_max * sizeof(recipient_item), FALSE);
   if (oldlist)
     memcpy(recipients_list, oldlist, oldmax * sizeof(recipient_item));
@@ -2561,11 +2561,12 @@ if (extract_recip)
           &domain, FALSE);
 
 #ifdef SUPPORT_I18N
-       if (string_is_utf8(recipient))
-         message_smtputf8 = TRUE;
-       else
-         allow_utf8_domains = b;
+        if (recipient)
+          if (string_is_utf8(recipient)) message_smtputf8 = TRUE;
+          else allow_utf8_domains = b;
        }
+#else
+        ;
 #endif
 
         /* Keep a list of all the bad addresses so we can send a single