commit 53b354a9b87cfe0696ef8411dec25f45b7ca6f41 from: Martijn van Duren date: Sun Apr 12 10:33:04 2020 UTC Prepare for opensmtpd protocol version 0.6. While here, 1 minor markup thingy commit - 06220a702a876245348b8dad461557562521dda3 commit + 53b354a9b87cfe0696ef8411dec25f45b7ca6f41 blob - 626f0f6e2b3ff5fcb3d1c3da7d91b822ddf62b3e blob + 539bac7cc375424390dff3068a761144925e0099 --- opensmtpd.c +++ opensmtpd.c @@ -1402,6 +1402,7 @@ osmtpd_tx_mail(struct osmtpd_callback *cb, struct osmt char *params, char *linedup) { char *end, *mailfrom; + enum osmtpd_status status; unsigned long imsgid; uint32_t msgid; void (*f)(struct osmtpd_ctx *, uint32_t, const char *, @@ -1425,15 +1426,20 @@ osmtpd_tx_mail(struct osmtpd_callback *cb, struct osmt osmtpd_errx(1, "Invalid line received: missing status: %s", linedup); end++[0] = '\0'; - mailfrom = params; + if (ctx->version_major == 0 && ctx->version_minor < 6) { + mailfrom = params; + status = osmtpd_strtostatus(end, linedup); + } else { + mailfrom = end; + status = osmtpd_strtostatus(params, linedup); + } if (cb->storereport) { if ((ctx->mailfrom = strdup(mailfrom)) == NULL) osmtpd_err(1, NULL); } - params = end; if ((f = cb->cb) != NULL) - f(ctx, msgid, mailfrom, osmtpd_strtostatus(params, linedup)); + f(ctx, msgid, mailfrom, status); } static void @@ -1441,6 +1447,7 @@ osmtpd_tx_rcpt(struct osmtpd_callback *cb, struct osmt char *params, char *linedup) { char *end, *rcptto; + enum osmtpd_status status; unsigned long imsgid; uint32_t msgid; size_t i; @@ -1466,8 +1473,13 @@ osmtpd_tx_rcpt(struct osmtpd_callback *cb, struct osmt linedup); end++[0] = '\0'; - rcptto = params; - params = end; + if (ctx->version_major == 0 && ctx->version_minor < 6) { + rcptto = params; + status = osmtpd_strtostatus(end, linedup); + } else { + rcptto = end; + status = osmtpd_strtostatus(params, linedup); + } if (cb->storereport) { for (i = 0; ctx->rcptto[i] != NULL; i++) @@ -1483,8 +1495,7 @@ osmtpd_tx_rcpt(struct osmtpd_callback *cb, struct osmt } if ((f = cb->cb) != NULL) - f(ctx, msgid, rcptto, - osmtpd_strtostatus(params, linedup)); + f(ctx, msgid, rcptto, status); } static void @@ -1953,8 +1964,8 @@ osmtpd_phasetostr(enum osmtpd_phase phase) osmtpd_errx(1, "In valid phase: %d\n", phase); } -static enum -osmtpd_status osmtpd_strtostatus(const char *status, char *linedup) +static enum osmtpd_status +osmtpd_strtostatus(const char *status, char *linedup) { if (strcmp(status, "ok") == 0) return OSMTPD_STATUS_OK;