-/* $OpenBSD: smtp_session.c,v 1.221 2014/12/17 15:49:23 millert Exp $ */
+/* $OpenBSD: smtp_session.c,v 1.222 2015/01/06 10:31:09 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
has_domain = 1;
if (buffer[i] == ':' && !escape && !comment && !quote)
has_group = 1;
- if (! isspace(buffer[i]))
+
+ /* update insert point if not in comment and not on a whitespace */
+ if (!comment && buffer[i] != ')' && !isspace((int)buffer[i]))
pos_component = i;
}
(void)strlcpy(s->smtpname, listener->hostname, sizeof(s->smtpname));
+ /* Setup parser and callbacks before smtp_connected() can be called */
+ rfc2822_parser_init(&s->rfc2822_parser);
+ rfc2822_header_default_callback(&s->rfc2822_parser,
+ header_default_callback, s);
+ rfc2822_header_callback(&s->rfc2822_parser, "bcc",
+ header_bcc_callback, s);
+ rfc2822_header_callback(&s->rfc2822_parser, "from",
+ header_masquerade_callback, s);
+ rfc2822_header_callback(&s->rfc2822_parser, "to",
+ header_masquerade_callback, s);
+ rfc2822_header_callback(&s->rfc2822_parser, "cc",
+ header_masquerade_callback, s);
+ rfc2822_body_callback(&s->rfc2822_parser,
+ dataline_callback, s);
+
/* For local enqueueing, the hostname is already set */
if (hostname) {
s->flags |= SF_AUTHENTICATED;
tree_xset(&wait_lka_ptr, s->id, s);
}
- rfc2822_parser_init(&s->rfc2822_parser);
- rfc2822_header_default_callback(&s->rfc2822_parser,
- header_default_callback, s);
- rfc2822_header_callback(&s->rfc2822_parser, "bcc",
- header_bcc_callback, s);
- rfc2822_header_callback(&s->rfc2822_parser, "from",
- header_masquerade_callback, s);
- rfc2822_header_callback(&s->rfc2822_parser, "to",
- header_masquerade_callback, s);
- rfc2822_header_callback(&s->rfc2822_parser, "cc",
- header_masquerade_callback, s);
- rfc2822_body_callback(&s->rfc2822_parser,
- dataline_callback, s);
+ /* session may have been freed by now */
return (0);
}