From 7c5a2df88c39af964bbf29bf8b8b8ba3aceedd98 Mon Sep 17 00:00:00 2001 From: Brendan Cully Date: Thu, 1 Jan 2009 16:55:32 -0800 Subject: [PATCH] SMTP: guard against short server responses --- smtp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/smtp.c b/smtp.c index 0dae118b..391eb0d3 100644 --- a/smtp.c +++ b/smtp.c @@ -89,9 +89,10 @@ smtp_get_resp (CONNECTION * conn) do { n = mutt_socket_readln (buf, sizeof (buf), conn); - if (n == -1) + if (n < 4) { + /* read error, or no response code */ return smtp_err_read; - n = atoi (buf); + } if (!ascii_strncasecmp ("8BITMIME", buf + 4, 8)) mutt_bit_set (Capabilities, EIGHTBITMIME); @@ -105,6 +106,8 @@ smtp_get_resp (CONNECTION * conn) mutt_bit_set (Capabilities, DSN); else if (!ascii_strncasecmp ("STARTTLS", buf + 4, 8)) mutt_bit_set (Capabilities, STARTTLS); + + n = atoi (buf); } while (buf[3] == '-'); if (smtp_success (n) || n == smtp_continue) -- 2.40.0