From 45ed6073097ba4081d52fd2667e47d82d5d6d3ad Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Sun, 20 Mar 2005 20:58:19 +0000 Subject: Fixes for header symbols. --- common/smtppass.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/common/smtppass.c b/common/smtppass.c index 6189262..dfa0176 100644 --- a/common/smtppass.c +++ b/common/smtppass.c @@ -1387,7 +1387,6 @@ static int make_header(spctx_t* ctx, const char* format_str, char* header) break; } - ++f; ++p; --remaining; } @@ -1422,24 +1421,28 @@ static int make_header(spctx_t* ctx, const char* format_str, char* header) remaining -= l; p += l; break; + case '%': + *p = '%'; + ++p; + break; default: - sp_message(ctx, LOG_WARNING, "invalid header symbol: %%%c", *f); + sp_messagex(ctx, LOG_WARNING, "invalid header symbol: %%%c", *f); break; }; } else { - *(p++) = *(f++); + *(p++) = *f; remaining--; } } - if(p < header + MAX_HEADER_LENGTH) - *p = 0; + if((p + 1) < (header + MAX_HEADER_LENGTH)) + p[1] = 0; header[MAX_HEADER_LENGTH - 1] = 0; l = p - header; - return (l > MAX_HEADER_LENGTH ? MAX_HEADER_LENGTH : l) - 1; + return l >= MAX_HEADER_LENGTH ? MAX_HEADER_LENGTH - 1 : l; } int sp_done_data(spctx_t* ctx) @@ -1875,7 +1878,7 @@ int sp_parse_option(const char* name, const char* value) g_state.header = trim_start(value); if(strlen(g_state.header) == 0) g_state.header = NULL; - else if(is_first_word(RCVD_HEADER, g_state.header, KL(RCVD_HEADER)) == 0) + else if(is_first_word(RCVD_HEADER, g_state.header, KL(RCVD_HEADER))) g_state.header_prepend = 1; ret = 1; } -- cgit v1.2.3