summaryrefslogtreecommitdiff
path: root/common/smtppass.c
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
commit85b24ec5498b8024d90243168ecc8e479e8e0e50 (patch)
treee111392ade3c09e19f38a42027953fb60c487391 /common/smtppass.c
parent08bf44b85193fd70c6a1d1fe195334b88bea1feb (diff)
Keep end of logline
Diffstat (limited to 'common/smtppass.c')
-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)