[exim-cvs] Revert "Avoid repeated string-copy building comm…

Kezdőlap
Üzenet törlése
Válasz az üzenetre
Szerző: Exim Git Commits Mailing List
Dátum:  
Címzett: exim-cvs
Tárgy: [exim-cvs] Revert "Avoid repeated string-copy building command-string for rspamd"
Gitweb: https://git.exim.org/exim.git/commitdiff/54f3613c5c633833c34c54fbd143a77c7fd7aceb
Commit:     54f3613c5c633833c34c54fbd143a77c7fd7aceb
Parent:     9377b957cdd0f1057db6efb7bccbde13e7d2a27a
Author:     Jeremy Harris <jgh146exb@???>
AuthorDate: Sat Jun 16 14:41:14 2018 +0100
Committer:  Jeremy Harris <jgh146exb@???>
CommitDate: Tue Jun 26 12:02:27 2018 +0100


    Revert "Avoid repeated string-copy building command-string for rspamd"


    This reverts commit 5df838645bcdb135355205a115bf918c85987caf.
---
 src/src/spam.c | 40 +++++++++++++++++++---------------------
 1 file changed, 19 insertions(+), 21 deletions(-)


diff --git a/src/src/spam.c b/src/src/spam.c
index 9384bfa..c9b3a02 100644
--- a/src/src/spam.c
+++ b/src/src/spam.c
@@ -370,28 +370,26 @@ start = time(NULL);
 (void)fcntl(spamd_cctx.sock, F_SETFL, O_NONBLOCK);
 /* now we are connected to spamd on spamd_cctx.sock */
 if (sd->is_rspamd)
-  {
-  gstring * req_str;
-  const uschar * s;
-
-  req_str = string_append(NULL, 8,
-    "CHECK RSPAMC/1.3\r\nContent-length: ", string_sprintf("%lu\r\n", mbox_size),
-    "Queue-Id: ", message_id,
-    "\r\nFrom: <", sender_address,
-    ">\r\nRecipient-Number: ", string_sprintf("%d\r\n", recipients_count));
-
+  {                /* rspamd variant */
+  uschar *req_str;
+  const uschar * helo;
+  const uschar * fcrdns;
+  const uschar * authid;
+
+  req_str = string_sprintf("CHECK RSPAMC/1.3\r\nContent-length: %lu\r\n"
+    "Queue-Id: %s\r\nFrom: <%s>\r\nRecipient-Number: %d\r\n",
+    mbox_size, message_id, sender_address, recipients_count);
   for (i = 0; i < recipients_count; i ++)
-    req_str = string_append(req_str, 3,
-      "Rcpt: <", recipients_list[i].address, ">\r\n");
-  if ((s = expand_string(US"$sender_helo_name")) && *s)
-    req_str = string_append(req_str, 3, "Helo: ", s, "\r\n");
-  if ((s = expand_string(US"$sender_host_name")) && *s)
-    req_str = string_append(req_str, 3, "Hostname: ", s, "\r\n");
-  if (sender_host_address)
-    req_str = string_append(req_str, 3, "IP: ", sender_host_address, "\r\n");
-  if ((s = expand_string(US"$authenticated_id")) && *s)
-    req_str = string_append(req_str, 3, "User: ", s, "\r\n");
-  req_str = string_catn(req_str, US"\r\n", 2);
+    req_str = string_sprintf("%sRcpt: <%s>\r\n", req_str, recipients_list[i].address);
+  if ((helo = expand_string(US"$sender_helo_name")) != NULL && *helo != '\0')
+    req_str = string_sprintf("%sHelo: %s\r\n", req_str, helo);
+  if ((fcrdns = expand_string(US"$sender_host_name")) != NULL && *fcrdns != '\0')
+    req_str = string_sprintf("%sHostname: %s\r\n", req_str, fcrdns);
+  if (sender_host_address != NULL)
+    req_str = string_sprintf("%sIP: %s\r\n", req_str, sender_host_address);
+  if ((authid = expand_string(US"$authenticated_id")) != NULL && *authid != '\0')
+    req_str = string_sprintf("%sUser: %s\r\n", req_str, authid);
+  req_str = string_sprintf("%s\r\n", req_str);
   wrote = send(spamd_cctx.sock, req_str->s, req_str->ptr, 0);
   }
 else