From a8bde366a125bc56b92c782480d7c5c890538f75 Mon Sep 17 00:00:00 2001 From: eric Date: Tue, 30 Jan 2018 12:44:55 +0000 Subject: [PATCH] don't reject smtp responses containing non-printable chars as long as the status is valid. use strnvis() for displaying status lines in "smtpctl show queue". ok gilles@ sunil@ --- usr.sbin/smtpd/smtpctl.c | 9 ++++++--- usr.sbin/smtpd/util.c | 9 +-------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/usr.sbin/smtpd/smtpctl.c b/usr.sbin/smtpd/smtpctl.c index 5642d1b5da2..76949609c1f 100644 --- a/usr.sbin/smtpd/smtpctl.c +++ b/usr.sbin/smtpd/smtpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpctl.c,v 1.156 2018/01/26 08:00:54 eric Exp $ */ +/* $OpenBSD: smtpctl.c,v 1.157 2018/01/30 12:44:55 eric Exp $ */ /* * Copyright (c) 2013 Eric Faurot @@ -41,6 +41,7 @@ #include #include #include +#include #include #include "smtpd.h" @@ -1165,7 +1166,7 @@ static void show_queue_envelope(struct envelope *e, int online) { const char *src = "?", *agent = "?"; - char status[128], runstate[128]; + char status[128], runstate[128], errline[LINE_MAX]; status[0] = '\0'; @@ -1210,6 +1211,8 @@ show_queue_envelope(struct envelope *e, int online) else if (e->ss.ss_family == AF_INET6) src = "inet6"; + strnvis(errline, e->errorline, sizeof(errline), 0); + printf("%016"PRIx64 "|%s|%s|%s|%s@%s|%s@%s|%s@%s" "|%zu|%zu|%zu|%zu|%s|%s\n", @@ -1228,7 +1231,7 @@ show_queue_envelope(struct envelope *e, int online) (size_t) e->lasttry, (size_t) e->retry, runstate, - e->errorline); + errline); } static void diff --git a/usr.sbin/smtpd/util.c b/usr.sbin/smtpd/util.c index 4a509ed4520..3700c7627c0 100644 --- a/usr.sbin/smtpd/util.c +++ b/usr.sbin/smtpd/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.132 2017/01/09 14:49:22 reyk Exp $ */ +/* $OpenBSD: util.c,v 1.133 2018/01/30 12:44:55 eric Exp $ */ /* * Copyright (c) 2000,2001 Markus Friedl. All rights reserved. @@ -685,8 +685,6 @@ session_socket_error(int fd) const char * parse_smtp_response(char *line, size_t len, char **msg, int *cont) { - size_t i; - if (len >= LINE_MAX) return "line too long"; @@ -708,11 +706,6 @@ parse_smtp_response(char *line, size_t len, char **msg, int *cont) !isdigit((unsigned char)line[2])) return "reply code out of range"; - /* validate reply message */ - for (i = 0; i < len; i++) - if (!isprint((unsigned char)line[i])) - return "non-printable character in reply"; - return NULL; } -- 2.20.1