]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/smtp/serv_smtp.c
* migrate convert_internet_message to StrBuf, the new approach saves tons of strlens...
[citadel.git] / citadel / modules / smtp / serv_smtp.c
index ca62fc3f024c3bdbe621eb8e31d8087739df44fc..2647a83a0e538395a02279ec5ee2117e10781442 100644 (file)
@@ -203,7 +203,10 @@ void smtp_msa_greeting(void) {
  * LMTP is like SMTP but with some extra bonus footage added.
  */
 void lmtp_greeting(void) {
+       citsmtp *sSMTP;
+
        smtp_greeting(0);
+       sSMTP = SMTP;
        SMTP->is_lmtp = 1;
 }
 
@@ -220,8 +223,10 @@ void smtp_mta_greeting(void) {
  * We also have an unfiltered LMTP socket that bypasses spam filters.
  */
 void lmtp_unfiltered_greeting(void) {
-       citsmtp *sSMTP = SMTP;
+       citsmtp *sSMTP;
+
        smtp_greeting(0);
+       sSMTP = SMTP;
        sSMTP->is_lmtp = 1;
        sSMTP->is_unfiltered = 1;
 }
@@ -662,7 +667,7 @@ void smtp_rcpt(char *argbuf) {
  * Implements the DATA command
  */
 void smtp_data(void) {
-       char *body;
+       StrBuf *body;
        struct CtdlMessage *msg = NULL;
        long msgnum = (-1L);
        char nowstamp[SIZ];
@@ -708,14 +713,14 @@ void smtp_data(void) {
                                 nowstamp);
                }
        }
-       body = CtdlReadMessageBody(".", config.c_maxmsglen, body, 1, 0);
+       body = CtdlReadMessageBodyBuf(HKEY("."), config.c_maxmsglen, body, 1, 0);
        if (body == NULL) {
                cprintf("550 Unable to save message: internal error.\r\n");
                return;
        }
 
        CtdlLogPrintf(CTDL_DEBUG, "Converting message...\n");
-       msg = convert_internet_message(body);
+       msg = convert_internet_message_buf(&body);
 
        /* If the user is locally authenticated, FORCE the From: header to
         * show up as the real sender.  Yes, this violates the RFC standard,
@@ -854,6 +859,10 @@ void smtp_command_loop(void) {
        char cmdbuf[SIZ];
        citsmtp *sSMTP = SMTP;
 
+       if (sSMTP == NULL) {
+               CtdlLogPrintf(CTDL_EMERG, "Session SMTP data is null.  WTF?  We will crash now.\n");
+       }
+
        time(&CC->lastcmd);
        memset(cmdbuf, 0, sizeof cmdbuf); /* Clear it, just in case */
        if (client_getln(cmdbuf, sizeof cmdbuf) < 1) {
@@ -1249,6 +1258,7 @@ void smtp_try(const char *key, const char *addr, int *status,
                CtdlLogPrintf(CTDL_WARNING, "Possible problem: message did not "
                        "correctly terminate. (expecting 0x10, got 0x%02x)\n",
                                buf[msg_size-1]);
+               sock_write(sock, "\r\n", 2);
        }
 
        sock_write(sock, ".\r\n", 3);