From bb097fbdb24fa07587fed9dd3d4135760866ccc3 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Fri, 16 Nov 2001 04:43:13 +0000 Subject: [PATCH] * Eliminated the sock_puts_crlf() function and ensured that all SMTP client commands are sent out using a single sock_write() call. There are broken SMTP server implementations that can't handle SMTP commands split across multiple writes. (Thanks to Andru Luvisi and Ben Mehlman for the idea.) --- citadel/ChangeLog | 7 +++++++ citadel/clientsocket.c | 16 ---------------- citadel/clientsocket.h | 1 - citadel/serv_smtp.c | 32 ++++++++++++++++---------------- 4 files changed, 23 insertions(+), 33 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index fb9a7840f..02d051502 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,10 @@ $Log$ + Revision 580.76 2001/11/16 04:43:12 ajc + * Eliminated the sock_puts_crlf() function and ensured that all SMTP client + commands are sent out using a single sock_write() call. There are broken + SMTP server implementations that can't handle SMTP commands split across + multiple writes. (Thanks to Andru Luvisi and Ben Mehlman for the idea.) + Revision 580.75 2001/11/15 04:11:30 ajc * hack.doc: updated to reflect Cit86Net compatibility fields removed from the file format (since we dumbed down the gateway software) @@ -2862,3 +2868,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import + diff --git a/citadel/clientsocket.c b/citadel/clientsocket.c index 286659aef..f096cdb34 100644 --- a/citadel/clientsocket.c +++ b/citadel/clientsocket.c @@ -201,19 +201,3 @@ int sock_puts(int sock, char *buf) if (j<0) return(j); return(i+j); } - - -/* - * sock_puts_crlf() - same as sock_puts() but ends line with CRLF, not LF - * Returns the number of bytes written, or -1 for error. - */ -int sock_puts_crlf(int sock, char *buf) -{ - int i, j; - - i = sock_write(sock, buf, strlen(buf)); - if (i<0) return(i); - j = sock_write(sock, "\r\n", 2); - if (j<0) return(j); - return(i+j); -} diff --git a/citadel/clientsocket.h b/citadel/clientsocket.h index cdcae4489..6bbe88db5 100644 --- a/citadel/clientsocket.h +++ b/citadel/clientsocket.h @@ -10,7 +10,6 @@ int sock_write(int sock, char *buf, int nbytes); int ml_sock_gets(int sock, char *buf); int sock_gets(int sock, char *buf); int sock_puts(int sock, char *buf); -int sock_puts_crlf(int sock, char *buf); /* * This looks dumb, but it's being done for future portability diff --git a/citadel/serv_smtp.c b/citadel/serv_smtp.c index 53a54881b..e3724487c 100644 --- a/citadel/serv_smtp.c +++ b/citadel/serv_smtp.c @@ -923,12 +923,12 @@ void smtp_try(char *key, char *addr, int *status, char *dsn, long msgnum) /* At this point we know we are talking to a real SMTP server */ /* Do a HELO command */ - snprintf(buf, sizeof buf, "HELO %s", config.c_fqdn); - lprintf(9, ">%s\n", buf); - sock_puts_crlf(sock, buf); + snprintf(buf, sizeof buf, "HELO %s\r\n", config.c_fqdn); + lprintf(9, ">%s", buf); + sock_write(sock, buf, strlen(buf)); if (ml_sock_gets(sock, buf) < 0) { *status = 4; - strcpy(dsn, "Connection broken during SMTP conversation"); + strcpy(dsn, "Connection broken during SMTP HELO"); goto bail; } lprintf(9, "<%s\n", buf); @@ -947,12 +947,12 @@ void smtp_try(char *key, char *addr, int *status, char *dsn, long msgnum) /* HELO succeeded, now try the MAIL From: command */ - snprintf(buf, sizeof buf, "MAIL From: <%s>", mailfrom); - lprintf(9, ">%s\n", buf); - sock_puts_crlf(sock, buf); + snprintf(buf, sizeof buf, "MAIL From: <%s>\r\n", mailfrom); + lprintf(9, ">%s", buf); + sock_write(sock, buf, strlen(buf)); if (ml_sock_gets(sock, buf) < 0) { *status = 4; - strcpy(dsn, "Connection broken during SMTP conversation"); + strcpy(dsn, "Connection broken during SMTP MAIL"); goto bail; } lprintf(9, "<%s\n", buf); @@ -971,12 +971,12 @@ void smtp_try(char *key, char *addr, int *status, char *dsn, long msgnum) /* MAIL succeeded, now try the RCPT To: command */ - snprintf(buf, sizeof buf, "RCPT To: <%s>", addr); - lprintf(9, ">%s\n", buf); - sock_puts_crlf(sock, buf); + snprintf(buf, sizeof buf, "RCPT To: <%s>\r\n", addr); + lprintf(9, ">%s", buf); + sock_write(sock, buf, strlen(buf)); if (ml_sock_gets(sock, buf) < 0) { *status = 4; - strcpy(dsn, "Connection broken during SMTP conversation"); + strcpy(dsn, "Connection broken during SMTP RCPT"); goto bail; } lprintf(9, "<%s\n", buf); @@ -996,10 +996,10 @@ void smtp_try(char *key, char *addr, int *status, char *dsn, long msgnum) /* RCPT succeeded, now try the DATA command */ lprintf(9, ">DATA\n"); - sock_puts_crlf(sock, "DATA"); + sock_write(sock, "DATA\r\n", 6); if (ml_sock_gets(sock, buf) < 0) { *status = 4; - strcpy(dsn, "Connection broken during SMTP conversation"); + strcpy(dsn, "Connection broken during SMTP DATA"); goto bail; } lprintf(9, "<%s\n", buf); @@ -1034,7 +1034,7 @@ void smtp_try(char *key, char *addr, int *status, char *dsn, long msgnum) sock_write(sock, ".\r\n", 3); if (ml_sock_gets(sock, buf) < 0) { *status = 4; - strcpy(dsn, "Connection broken during SMTP conversation"); + strcpy(dsn, "Connection broken during SMTP message transmit"); goto bail; } lprintf(9, "%s\n", buf); @@ -1056,7 +1056,7 @@ void smtp_try(char *key, char *addr, int *status, char *dsn, long msgnum) *status = 2; lprintf(9, ">QUIT\n"); - sock_puts_crlf(sock, "QUIT"); + sock_write(sock, "QUIT\r\n", 6); ml_sock_gets(sock, buf); lprintf(9, "<%s\n", buf); -- 2.39.2