+2009-06-01 11:26 +0200 Rocco Rutte <pdmef@gmx.net> (35a444838167)
+
+ * curs_main.c, edit.c, init.c, main.c, menu.c, mh.c, parse.c,
+ resize.c, score.c, url.c: Use strtol() wrappers for most atoi()
+ calls
+
+2009-06-01 11:24 +0200 Rocco Rutte <pdmef@gmx.net> (f1b6eb09f2ad)
+
+ * ChangeLog, lib.c, lib.h: Add mutt_atos(), mutt_atoi() and
+ mutt_atol() (strtol() wrappers)
+
2009-06-01 10:36 +0200 Rocco Rutte <pdmef@gmx.net> (36b7e267ce33)
* send.c: Treat address groups as no recipients
#define smtp_err_read -2
#define smtp_err_write -3
+#define smtp_err_code -4
#define SMTP_PORT 25
#define SMTPS_PORT 465
static char* AuthMechs = NULL;
static unsigned char Capabilities[(CAPMAX + 7)/ 8];
+static int smtp_code (char *buf, size_t len, int *n)
+{
+ char code[3];
+
+ if (len < 4)
+ return -1;
+ code[0] = buf[0];
+ code[1] = buf[1];
+ code[2] = buf[2];
+ code[3] = 0;
+ if (mutt_atoi (code, n) < 0)
+ return -1;
+ return 0;
+}
+
/* Reads a command response from the SMTP server.
* Returns:
* 0 on success (2xx code) or continue (354 code)
else if (!ascii_strncasecmp ("STARTTLS", buf + 4, 8))
mutt_bit_set (Capabilities, STARTTLS);
- n = atoi (buf);
+ if (smtp_code (buf, n, &n) < 0)
+ return smtp_err_code;
+
} while (buf[3] == '-');
if (smtp_success (n) || n == smtp_continue)
mutt_error (_("SMTP session failed: read error"));
else if (ret == smtp_err_write)
mutt_error (_("SMTP session failed: write error"));
+ else if (ret == smtp_err_code)
+ mutt_error (_("Invalid server response"));
return ret;
}
do {
if (mutt_socket_write (conn, buf) < 0)
goto fail;
- if (mutt_socket_readln (buf, sizeof (buf), conn) < 0)
+ if ((rc = mutt_socket_readln (buf, sizeof (buf), conn)) < 0)
+ goto fail;
+ if (smtp_code (buf, rc, &rc) < 0)
goto fail;
- rc = atoi(buf);
if (rc != smtp_ready)
break;