From da071e05139bde1ff29c8a06c72ecfbfbda02f28 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Fri, 14 Mar 2008 18:39:38 +0000 Subject: [PATCH] Rewrote the sender/recipients/dsn display code in smtpqueue.c This version avoids excessive strlen and displays the complete data. --- webcit/smtpqueue.c | 65 +++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 36 deletions(-) diff --git a/webcit/smtpqueue.c b/webcit/smtpqueue.c index 1a2251aea..d7eceb046 100644 --- a/webcit/smtpqueue.c +++ b/webcit/smtpqueue.c @@ -1,15 +1,13 @@ /* * $Id$ + * + * Display the outbound SMTP queue */ -/** - * \defgroup SMTPqueue Display the outbound SMTP queue - * \ingroup CitadelConfig - */ -/*@{*/ + #include "webcit.h" -/** - * \brief display one message in the queue +/* + * display one message in the queue */ void display_queue_msg(long msgnum) { @@ -23,13 +21,17 @@ void display_queue_msg(long msgnum) int number_of_attempts = 0; char sender[256]; char recipients[65536]; + int recipients_len = 0; char thisrecp[256]; char thisdsn[256]; + char thismsg[512]; + int thismsg_len; long msgid = 0; int len; strcpy(sender, ""); strcpy(recipients, ""); + recipients_len = 0; serv_printf("MSG2 %ld", msgnum); serv_getln(buf, sizeof buf); @@ -96,38 +98,29 @@ void display_queue_msg(long msgnum) } if (!strcasecmp(keyword, "remote")) { - int RcptLen; - int TRcptLen; - int TDsn; - int NLen; + thismsg[0] = 0; + extract_token(thisrecp, buf, 1, '|', sizeof thisrecp); extract_token(thisdsn, buf, 3, '|', sizeof thisdsn); - RcptLen = strlen(recipients); - TRcptLen = strlen(thisrecp); - TDsn = strlen(thisdsn); - if ( RcptLen + TRcptLen + TDsn + 100 - < sizeof recipients) { - if (!IsEmptyStr(recipients)) { - // copy the \0 to be sure.. - memcpy (&recipients[RcptLen], "
\0", 7); - RcptLen += 6; + + if (!IsEmptyStr(thisrecp)) { + stresc(thismsg, sizeof thismsg, thisrecp, 1, 1); + if (!IsEmptyStr(thisdsn)) { + strcat(thismsg, "
  "); + stresc(&thismsg[strlen(thismsg)], sizeof thismsg, + thisdsn, 1, 1); + strcat(thismsg, ""); + } + thismsg_len = strlen(thismsg); + + if ((recipients_len + thismsg_len + 100) < sizeof recipients) { + if (!IsEmptyStr(recipients)) { + strcpy(&recipients[recipients_len], "
"); + recipients_len += 6; + } + strcpy(&recipients[recipients_len], thismsg); + recipients_len += thismsg_len; } - NLen = stresc(&recipients[RcptLen], - sizeof recipients - RcptLen, - thisrecp, 1, 1); - if (NLen != -1) - { - RcptLen += NLen; - NLen = sizeof "
  "; - memcpy(recipients, "
  ", - NLen); - RcptLen += NLen - 1; - NLen = stresc(&recipients[RcptLen], - sizeof recipients - RcptLen, - thisdsn, 1, 1); - if (NLen != -1) - memcpy (recipients, "\0", 5); - } /// else bail out? } } -- 2.30.2