diff options
author | Gilles Chehade <gilles@cvs.openbsd.org> | 2018-10-31 16:45:25 +0000 |
---|---|---|
committer | Gilles Chehade <gilles@cvs.openbsd.org> | 2018-10-31 16:45:25 +0000 |
commit | 15adfa3fe255d0ee3bc62f437f5b8bad731e0307 (patch) | |
tree | 57b530b4998d3d7e284dff41d5c47a29e1fc16ca /usr.sbin/smtpd | |
parent | 8e000243438a9946ec77f5a6698540eab16b48c4 (diff) |
smtp_tx_mail_from() and smtp_tx_rcpt_to() should take a const char *line
Diffstat (limited to 'usr.sbin/smtpd')
-rw-r--r-- | usr.sbin/smtpd/smtp_session.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/usr.sbin/smtpd/smtp_session.c b/usr.sbin/smtpd/smtp_session.c index 722f4559c6e..c00ef73963e 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.339 2018/10/31 16:40:35 gilles Exp $ */ +/* $OpenBSD: smtp_session.c,v 1.340 2018/10/31 16:45:24 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -181,8 +181,8 @@ static void smtp_auth_failure_resume(int, short, void *); static int smtp_tx(struct smtp_session *); static void smtp_tx_free(struct smtp_tx *); static void smtp_tx_create_message(struct smtp_tx *); -static void smtp_tx_mail_from(struct smtp_tx *, char *); -static void smtp_tx_rcpt_to(struct smtp_tx *, char *); +static void smtp_tx_mail_from(struct smtp_tx *, const char *); +static void smtp_tx_rcpt_to(struct smtp_tx *, const char *); static void smtp_tx_open_message(struct smtp_tx *); static void smtp_tx_commit(struct smtp_tx *); static void smtp_tx_rollback(struct smtp_tx *); @@ -1995,11 +1995,16 @@ smtp_tx_free(struct smtp_tx *tx) } static void -smtp_tx_mail_from(struct smtp_tx *tx, char *line) +smtp_tx_mail_from(struct smtp_tx *tx, const char *line) { char *opt; + char *copy; + char tmp[SMTP_LINE_MAX]; - if (smtp_mailaddr(&tx->evp.sender, line, 1, &line, + (void)strlcpy(tmp, line, sizeof tmp); + copy = tmp; + + if (smtp_mailaddr(&tx->evp.sender, copy, 1, ©, tx->session->smtpname) == 0) { smtp_reply(tx->session, "553 %s: Sender address syntax error", esc_code(ESC_STATUS_PERMFAIL, ESC_OTHER_ADDRESS_STATUS)); @@ -2007,7 +2012,7 @@ smtp_tx_mail_from(struct smtp_tx *tx, char *line) return; } - while ((opt = strsep(&line, " "))) { + while ((opt = strsep(©, " "))) { if (*opt == '\0') continue; @@ -2071,9 +2076,14 @@ smtp_tx_create_message(struct smtp_tx *tx) } static void -smtp_tx_rcpt_to(struct smtp_tx *tx, char *line) +smtp_tx_rcpt_to(struct smtp_tx *tx, const char *line) { char *opt, *p; + char *copy; + char tmp[SMTP_LINE_MAX]; + + (void)strlcpy(tmp, line, sizeof tmp); + copy = tmp; if (tx->rcptcount >= env->sc_session_max_rcpt) { smtp_reply(tx->session, "451 %s %s: Too many recipients", @@ -2082,7 +2092,7 @@ smtp_tx_rcpt_to(struct smtp_tx *tx, char *line) return; } - if (smtp_mailaddr(&tx->evp.rcpt, line, 0, &line, + if (smtp_mailaddr(&tx->evp.rcpt, copy, 0, ©, tx->session->smtpname) == 0) { smtp_reply(tx->session, "501 %s: Recipient address syntax error", @@ -2091,7 +2101,7 @@ smtp_tx_rcpt_to(struct smtp_tx *tx, char *line) return; } - while ((opt = strsep(&line, " "))) { + while ((opt = strsep(©, " "))) { if (*opt == '\0') continue; |