use SIZE parameter to avoid sending too big, rejected, messages
authorColin Leroy <colin@colino.net>
Mon, 5 Jul 2004 16:36:44 +0000 (16:36 +0000)
committerColin Leroy <colin@colino.net>
Mon, 5 Jul 2004 16:36:44 +0000 (16:36 +0000)
ChangeLog.claws
configure.ac
src/common/smtp.c
src/common/smtp.h

index 15fb4f5..726b8e1 100644 (file)
@@ -1,3 +1,9 @@
+2004-07-05 [colin]     0.9.12cvs8
+
+       * src/common/smtp.[ch]
+               Take SIZE (returned by EHLO) into account, and
+               avoid sending too big messages
+
 2004-07-04 [paul]      0.9.12cvs7
 
        * src/account.c
index 336ba86..e2c3b41 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=12
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=7
+EXTRA_VERSION=8
 EXTRA_RELEASE=
 
 if test \( $EXTRA_VERSION -eq 0 \) -o \( "x$EXTRA_RELEASE" != "x" \); then
index 39ccbb9..7811f96 100644 (file)
@@ -90,6 +90,8 @@ Session *smtp_session_new(void)
        session->send_data                 = NULL;
        session->send_data_len             = 0;
 
+       session->max_message_size          = -1;
+
        session->avail_auth_type           = 0;
        session->forced_auth_type          = 0;
        session->auth_type                 = 0;
@@ -276,6 +278,10 @@ static gint smtp_ehlo_recv(SMTPSession *session, const gchar *msg)
                        if (strcasestr(p, "DIGEST-MD5"))
                                session->avail_auth_type |= SMTPAUTH_DIGEST_MD5;
                }
+               if (g_strncasecmp(p, "SIZE", 4) == 0) {
+                       p += 5;
+                       session->max_message_size = atoi(p);
+               }
                return SM_OK;
        } else if ((msg[0] == '1' || msg[0] == '2' || msg[0] == '3') &&
            (msg[3] == ' ' || msg[3] == '\0'))
@@ -492,6 +498,13 @@ static gint smtp_session_recv_msg(Session *session, const gchar *msg)
                smtp_ehlo_recv(smtp_session, msg);
                if (cont == TRUE)
                        break;
+               if (smtp_session->max_message_size > 0
+               && smtp_session->max_message_size < smtp_session->send_data_len) {
+                       log_warning(_("Message is too big\n"));
+                       smtp_session->state = SMTP_ERROR;
+                       smtp_session->error_val = SM_ERROR;
+                       return -1;
+               }
 #if USE_OPENSSL
                if (session->ssl_type == SSL_STARTTLS &&
                    smtp_session->tls_init_done == FALSE) {
index a8234f5..4212234 100644 (file)
@@ -103,6 +103,8 @@ struct _SMTPSession
        guchar *send_data;
        guint send_data_len;
 
+       guint max_message_size;
+
        SMTPAuthType avail_auth_type;
        SMTPAuthType forced_auth_type;
        SMTPAuthType auth_type;