summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/smtppass.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/common/smtppass.c b/common/smtppass.c
index 72ca71c..468991a 100644
--- a/common/smtppass.c
+++ b/common/smtppass.c
@@ -1314,6 +1314,7 @@ cleanup:
int sp_fail_data(spctx_t* ctx, const char* smtp_status)
{
+ char buf[256 + KL(SMTP_REJPREFIX) + KL(CRLF) + 1];
char* t = NULL;
int len, x;
int pref = 0;
@@ -1335,14 +1336,11 @@ int sp_fail_data(spctx_t* ctx, const char* smtp_status)
if(pref || crlf)
{
- x = (len > 256 ? 256 : len) + KL(SMTP_REJPREFIX) + KL(CRLF) + 1;
- t = (char*)alloca(x + 1);
-
/* Note that we truncate long lines */
- snprintf(t, x, "%s%.256s%s", pref ? SMTP_REJPREFIX : "",
+ snprintf(buf, sizeof(buf), "%s%.256s%s", pref ? SMTP_REJPREFIX : "",
smtp_status, crlf ? CRLF : "");
- t[x] = 0;
- smtp_status = t;
+ buf[sizeof(buf) - 1] = 0;
+ smtp_status = buf;
}
if(spio_write_data(ctx, &(ctx->client), smtp_status) == -1)