- report(stdout, "%cMTP< %s\n", smtp_mode, smtp_response);
- if ((smtp_response[0] == '1' || smtp_response[0] == '2' || smtp_response[0] == '3') && smtp_response[3] == ' ')
+ report(stdout, "%cMTP< %s\n", smtp_mode, reply);
+ /* note that \0 is part of the strchr search string and the
+ * blank after the reply code is optional (RFC 5321 4.2.1) */
+ if (n < 3 || !strchr(" -", reply[3]))
+ {
+ if (outlevel >= O_MONITOR)
+ report(stderr, GT_("smtp listener protocol error\n"));
+ return SM_UNRECOVERABLE;
+ }
+
+ last_smtp_ok = time((time_t *) NULL);
+
+ strlcat(smtp_response, reply, sizeof(smtp_response));
+
+ if (strchr("123", reply[0])
+ && isdigit((unsigned char)reply[1])
+ && isdigit((unsigned char)reply[2])
+ && strchr(" ", reply[3])) /* matches space and \0 */ {