summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2004-10-08 01:04:27 +0000
committerStef Walter <stef@memberwebs.com>2004-10-08 01:04:27 +0000
commitf9bd5f80131da43080e0f64405167599949c7ea9 (patch)
tree5596a1f836f03fbed8f8721d58aec2f962e27de9 /common
parent296ae6560f61a05b022a53e8090cd7acf349419c (diff)
Keep end of logline
Diffstat (limited to 'common')
-rw-r--r--common/smtppass.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/common/smtppass.c b/common/smtppass.c
index 9e50c55..e00f7a1 100644
--- a/common/smtppass.c
+++ b/common/smtppass.c
@@ -1090,23 +1090,35 @@ static const char* get_successful_rsp(const char* line, int* cont)
void sp_add_log(spctx_t* ctx, char* prefix, char* line)
{
- int l = SP_LINE_LENGTH;
char* t = ctx->logline;
+ int l = strlen(t);
+ int x;
- ASSERT(l >= 0);
+ ASSERT(l <= SP_LINE_LENGTH);
- if(t[0] != 0)
- strlcat(ctx->logline, ", ", l);
+ /* Add up necessary lengths */
+ x = 2 + strlen(prefix) + strlen(line) + 1;
- strlcat(ctx->logline, prefix, l);
+ if(l + x >= SP_LINE_LENGTH)
+ l = SP_LINE_LENGTH - x;
+
+ t += l;
+ l = SP_LINE_LENGTH - l;
+
+ *t = 0;
+
+ if(ctx->logline[0] != 0)
+ strlcat(t, ", ", l);
+
+ strlcat(t, prefix, l);
/* Skip initial white space */
line = trim_start(line);
- strlcat(ctx->logline, line, l);
+ strlcat(t, line, l);
/* Skip later white space */
- trim_end(ctx->logline);
+ trim_end(t);
}
int sp_read_data(spctx_t* ctx, const char** data)