constify
[exim.git] / src / src / dmarc.c
index f29f7eba6af4bffb591ab839d45615ebc529ee8e..be9c4b384057c6c94c9ffc23038243680e8a3f14 100644 (file)
@@ -109,15 +109,15 @@ if (libdm_status != DMARC_PARSE_OKAY)
                       opendmarc_policy_status_to_str(libdm_status));
   dmarc_abort = TRUE;
   }
-if (!dmarc_tld_file)
+if (!dmarc_tld_file || !*dmarc_tld_file)
   {
   DEBUG(D_receive) debug_printf("DMARC: no dmarc_tld_file\n");
   dmarc_abort = TRUE;
   }
 else if (opendmarc_tld_read_file(CS dmarc_tld_file, NULL, NULL, NULL))
   {
-  log_write(0, LOG_MAIN|LOG_PANIC, "DMARC failure to load tld list %s: %d",
-                      dmarc_tld_file, errno);
+  log_write(0, LOG_MAIN|LOG_PANIC, "DMARC failure to load tld list '%s': %s",
+                      dmarc_tld_file, strerror(errno));
   dmarc_abort = TRUE;
   }
 if (!sender_host_address)
@@ -157,7 +157,6 @@ return OK;
 static void
 dmarc_send_forensic_report(u_char **ruf)
 {
-int   c;
 uschar *recipient, *save_sender;
 BOOL  send_status = FALSE;
 error_block *eblock = NULL;
@@ -183,7 +182,7 @@ if (  dmarc_policy == DMARC_POLICY_REJECT     && action == DMARC_RESULT_REJECT
                     da == DMARC_POLICY_DKIM_ALIGNMENT_PASS ? US"yes" : US"no");
     eblock = add_to_eblock(eblock, US"DMARC Results", dmarc_status_text);
 
-    for (c = 0; ruf[c]; c++)
+    for (int c = 0; ruf[c]; c++)
       {
       recipient = string_copylc(ruf[c]);
       if (Ustrncmp(recipient, "mailto:",7))
@@ -399,11 +398,11 @@ if (!dmarc_abort && !sender_host_authenticated)
   /* Can't use exim's string manipulation functions so allocate memory
   for libopendmarc using its max hostname length definition. */
 
-  dmarc_domain = US calloc(DMARC_MAXHOSTNAMELEN, sizeof(uschar));
+  dmarc_domain = store_get(DMARC_MAXHOSTNAMELEN, TRUE);
   libdm_status = opendmarc_policy_fetch_utilized_domain(dmarc_pctx,
     dmarc_domain, DMARC_MAXHOSTNAMELEN-1);
-  dmarc_used_domain = string_copy(dmarc_domain);
-  free(dmarc_domain);
+  store_release_above(dmarc_domain + Ustrlen(dmarc_domain)+1);
+  dmarc_used_domain = dmarc_domain;
 
   if (libdm_status != DMARC_PARSE_OKAY)
     log_write(0, LOG_MAIN|LOG_PANIC,