summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2005-11-15 16:40:11 +0000
committerStef Walter <stef@memberwebs.com>2005-11-15 16:40:11 +0000
commit2278c77507c0659229cbb6b622be0e30c1743c79 (patch)
treed16e9a2b7a64500d74e830793ac084344a5d22eb /common
parente36d27a2a68afae0792f1808e13b2863f5c7dff9 (diff)
Possible fix for crasher when in debug mode. (Try not using alloca).
Diffstat (limited to 'common')
-rw-r--r--common/smtppass.c42
1 files changed, 18 insertions, 24 deletions
diff --git a/common/smtppass.c b/common/smtppass.c
index f8129ed..677277f 100644
--- a/common/smtppass.c
+++ b/common/smtppass.c
@@ -1710,13 +1710,12 @@ void sp_setup_forked(spctx_t* ctx, int file)
*/
const char kMsgDelimiter[] = ": ";
-#define MAX_MSGLEN 256
+#define MAX_MSGLEN 1024
static void vmessage(spctx_t* ctx, int level, int err,
const char* msg, va_list ap)
{
- size_t len;
- char* m;
+ char buf[MAX_MSGLEN];
int e = errno;
if(g_state.daemonized)
@@ -1732,35 +1731,30 @@ static void vmessage(spctx_t* ctx, int level, int err,
ASSERT(msg);
- len = strlen(msg) + 20 + MAX_MSGLEN;
- m = (char*)alloca(len);
+ if(ctx)
+ snprintf(buf, MAX_MSGLEN, "%06X: %s%s", ctx->id, msg, err ? ": " : "");
+ else
+ snprintf(buf, MAX_MSGLEN, "%s%s", msg, err ? ": " : "");
- if(m)
+ if(err)
{
- if(ctx)
- snprintf(m, len, "%06X: %s%s", ctx->id, msg, err ? ": " : "");
- else
- snprintf(m, len, "%s%s", msg, err ? ": " : "");
-
- if(err)
- {
- /* strerror_r doesn't want to work for us for some reason
- strerror_r(e, m + strlen(m), MAX_MSGLEN); */
+ /* strerror_r doesn't want to work for us for some reason
+ len = strlen(buf);
+ strerror_r(e, buf + len, MAX_MSGLEN - len); */
- sp_lock();
- strncat(m, strerror(e), len);
- sp_unlock();
- }
-
- m[len - 1] = 0;
- msg = m;
+ sp_lock();
+ strncat(buf, strerror(e), MAX_MSGLEN);
+ sp_unlock();
}
+ /* As a precaution */
+ buf[MAX_MSGLEN - 1] = 0;
+
/* Either to syslog or stderr */
if(g_state.daemonized)
- vsyslog(level, msg, ap);
+ vsyslog(level, buf, ap);
else
- vwarnx(msg, ap);
+ vwarnx(buf, ap);
}
void sp_messagex(spctx_t* ctx, int level, const char* msg, ...)