diff options
author | Gilles Chehade <gilles@cvs.openbsd.org> | 2009-09-12 09:22:34 +0000 |
---|---|---|
committer | Gilles Chehade <gilles@cvs.openbsd.org> | 2009-09-12 09:22:34 +0000 |
commit | 826dc1a7c1baec9e10f8c6c94c8361e82b2e476c (patch) | |
tree | 0c0a156df4a3ecc528e70f61cdfd6df6ba5ce38b /usr.sbin | |
parent | 164736bd059d0cbfd8ef6da3b220485deb414db0 (diff) |
- fix a compile time warning
- add a new stats counter to distinguish between command lines which
exceeded the limit and data lines which exceeded the limits
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/smtpd/smtp_session.c | 9 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpctl.c | 5 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpd.h | 9 |
3 files changed, 13 insertions, 10 deletions
diff --git a/usr.sbin/smtpd/smtp_session.c b/usr.sbin/smtpd/smtp_session.c index b16b1625e4d..54c898f9900 100644 --- a/usr.sbin/smtpd/smtp_session.c +++ b/usr.sbin/smtpd/smtp_session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtp_session.c,v 1.116 2009/09/12 09:01:19 gilles Exp $ */ +/* $OpenBSD: smtp_session.c,v 1.117 2009/09/12 09:22:33 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -836,8 +836,9 @@ session_read_data(struct session *s, char *line, size_t nread) if (s->s_msg.status & (S_MESSAGE_PERMFAILURE|S_MESSAGE_TEMPFAILURE)) return; - if (nread > SMTP_TEXTLINE_MAX) { + if (nread > SMTP_DATALINE_MAX) { s->s_msg.status |= S_MESSAGE_PERMFAILURE; + s->s_env->stats->smtp.datalinetoolong++; return; } @@ -849,7 +850,7 @@ session_read_data(struct session *s, char *line, size_t nread) len = strlen(line); - if (fprintf(s->datafp, "%s\n", line) != len + 1) { + if (fprintf(s->datafp, "%s\n", line) != (int)len + 1) { s->s_msg.status |= S_MESSAGE_TEMPFAILURE; return; } @@ -1004,7 +1005,7 @@ session_readline(struct session *s, size_t *nr) if (line == NULL) { if (EVBUFFER_LENGTH(s->s_bev->input) > SMTP_ANYLINE_MAX) { session_respond(s, "500 Line too long"); - s->s_env->stats->smtp.linetoolong++; + s->s_env->stats->smtp.cmdlinetoolong++; s->s_flags |= F_QUIT; } return NULL; diff --git a/usr.sbin/smtpd/smtpctl.c b/usr.sbin/smtpd/smtpctl.c index 562febd7ad7..4f247de8fd4 100644 --- a/usr.sbin/smtpd/smtpctl.c +++ b/usr.sbin/smtpd/smtpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpctl.c,v 1.35 2009/09/02 12:47:06 jacekm Exp $ */ +/* $OpenBSD: smtpctl.c,v 1.36 2009/09/12 09:22:33 gilles Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -282,7 +282,8 @@ show_stats_output(struct imsg *imsg) printf("runner.active=%zd\n", stats->runner.active); printf("smtp.errors.delays=%zd\n", stats->smtp.delays); - printf("smtp.errors.linetoolong=%zd\n", stats->smtp.linetoolong); + printf("smtp.errors.cmdlinetoolong=%zd\n", stats->smtp.cmdlinetoolong); + printf("smtp.errors.datalinetoolong=%zd\n", stats->smtp.datalinetoolong); printf("smtp.errors.read_eof=%zd\n", stats->smtp.read_eof); printf("smtp.errors.read_system=%zd\n", stats->smtp.read_error); printf("smtp.errors.read_timeout=%zd\n", stats->smtp.read_timeout); diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h index d539be9b01c..e6a9faaab10 100644 --- a/usr.sbin/smtpd/smtpd.h +++ b/usr.sbin/smtpd/smtpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.h,v 1.139 2009/09/04 11:49:23 jacekm Exp $ */ +/* $OpenBSD: smtpd.h,v 1.140 2009/09/12 09:22:33 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -88,9 +88,9 @@ #define FAST_RESPONSES 2 /* rfc5321 limits */ -#define SMTP_TEXTLINE_MAX 1000 +#define SMTP_DATALINE_MAX 1000 #define SMTP_CMDLINE_MAX 512 -#define SMTP_ANYLINE_MAX SMTP_TEXTLINE_MAX +#define SMTP_ANYLINE_MAX SMTP_DATALINE_MAX #define F_STARTTLS 0x01 #define F_SMTPS 0x02 @@ -664,7 +664,8 @@ struct s_session { size_t write_eof; size_t toofast; size_t tempfail; - size_t linetoolong; + size_t cmdlinetoolong; + size_t datalinetoolong; size_t delays; }; |