summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2010-04-21 20:32:58 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2010-04-21 20:32:58 +0000
commit3a6c3f70ccba017c1fb037d499db12391127122d (patch)
tree24e500555a6748b0ab2ee8d288d27e46f3998127
parent44e369f8aae25b46fb133a98624f3ba2042ff9e8 (diff)
my evbuffer_readln_crlf() hack can be killed now that nicm@ has brought us
an update to libevent that ships with evbuffer_readln(). beers for nicm@ !
-rw-r--r--usr.sbin/smtpd/smtp_session.c41
1 files changed, 4 insertions, 37 deletions
diff --git a/usr.sbin/smtpd/smtp_session.c b/usr.sbin/smtpd/smtp_session.c
index 976be022ea6..71cb9d1a12b 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.130 2010/04/19 10:26:40 gilles Exp $ */
+/* $OpenBSD: smtp_session.c,v 1.131 2010/04/21 20:32:57 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -74,7 +74,6 @@ void session_respond_delayed(int, short, void *);
int session_set_path(struct path *, char *);
void session_imsg(struct session *, enum smtp_proc_type,
enum imsg_type, u_int32_t, pid_t, int, void *, u_int16_t);
-char *evbuffer_readln_crlf(struct evbuffer *);
struct session_cmd {
char *name;
@@ -1014,7 +1013,7 @@ session_readline(struct session *s)
size_t nr;
nr = EVBUFFER_LENGTH(s->s_bev->input);
- line = evbuffer_readln_crlf(s->s_bev->input);
+ line = evbuffer_readln(s->s_bev->input, NULL, EVBUFFER_EOL_CRLF);
if (line == NULL) {
if (EVBUFFER_LENGTH(s->s_bev->input) > SMTP_LINE_MAX) {
session_respond(s, "500 5.0.0 Line too long");
@@ -1036,7 +1035,8 @@ session_readline(struct session *s)
}
if ((s->s_state != S_DATACONTENT || strcmp(line, ".") == 0) &&
- (line2 = evbuffer_readln_crlf(s->s_bev->input)) != NULL) {
+ (line2 = evbuffer_readln(s->s_bev->input, NULL,
+ EVBUFFER_EOL_CRLF)) != NULL) {
session_respond(s, "500 5.0.0 Pipelining unsupported");
s->s_env->stats->smtp.toofast++;
s->s_flags |= F_QUIT;
@@ -1180,37 +1180,4 @@ session_imsg(struct session *s, enum smtp_proc_type proc, enum imsg_type type,
datalen);
}
-char *
-evbuffer_readln_crlf(struct evbuffer *buffer)
-{
- u_char *data = EVBUFFER_DATA(buffer);
- size_t len = EVBUFFER_LENGTH(buffer);
- char *line;
- unsigned int i, j;
-
- for (i = 0; i < len; ++i) {
- if (data[i] == '\n')
- break;
- }
-
- if (i == len)
- return NULL;
-
- j = i;
- if (i != 0 && data[i - 1] == '\r')
- --j;
-
- line = calloc(j + 1, 1);
- if (line == NULL)
- fatal("calloc");
-
- if (j != 0)
- memcpy(line, data, j);
-
- evbuffer_drain(buffer, i + 1);
-
- return (line);
-}
-
-
SPLAY_GENERATE(sessiontree, session, s_nodes, session_cmp);