From dd37f97a862be2eb3b277eedea80d6a4fd42719f Mon Sep 17 00:00:00 2001 From: Gilles Chehade Date: Sat, 12 Sep 2009 09:50:32 +0000 Subject: 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 --- usr.sbin/smtpd/smtp_session.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'usr.sbin') 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 @@ -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; } -- cgit v1.2.3