diff options
author | Gilles Chehade <gilles@cvs.openbsd.org> | 2009-09-12 09:50:32 +0000 |
---|---|---|
committer | Gilles Chehade <gilles@cvs.openbsd.org> | 2009-09-12 09:50:32 +0000 |
commit | dd37f97a862be2eb3b277eedea80d6a4fd42719f (patch) | |
tree | d209d830192c4f3e011149c169d0c8e5c628aa4e /usr.sbin/smtpd | |
parent | 2c98bd94179faa79d880be3373e0ac0de7787d66 (diff) |
fix a wrong computation in session_readline() where the length of line was
deduced from the buffer size prior and after evbuffer_readline() call. the
problem is that this accounts for the characters which evbuffer_readline()
removed and we do not know how many they were (\n, \r\n ..). fix just does
a strlen() call of line which is a bit slower but way safer.
This could very well fix the broken headers issue some people reported
Diffstat (limited to 'usr.sbin/smtpd')
-rw-r--r-- | usr.sbin/smtpd/smtp_session.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/usr.sbin/smtpd/smtp_session.c b/usr.sbin/smtpd/smtp_session.c index 640e5162180..ac75eeace68 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.118 2009/09/12 09:38:45 gilles Exp $ */ +/* $OpenBSD: smtp_session.c,v 1.119 2009/09/12 09:50:31 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -1001,7 +1001,7 @@ session_readline(struct session *s, size_t *nr) { char *line, *line2; - *nr = EVBUFFER_LENGTH(s->s_bev->input); + *nr = 0; line = evbuffer_readline(s->s_bev->input); if (line == NULL) { if (EVBUFFER_LENGTH(s->s_bev->input) > SMTP_ANYLINE_MAX) { @@ -1011,7 +1011,6 @@ session_readline(struct session *s, size_t *nr) } return NULL; } - *nr -= EVBUFFER_LENGTH(s->s_bev->input); if (s->s_flags & F_WRITEONLY) fatalx("session_readline: corrupt session"); @@ -1027,6 +1026,7 @@ session_readline(struct session *s, size_t *nr) return NULL; } + *nr = strlen(line); return line; } |