-/* $OpenBSD: mta.c,v 1.185 2014/04/04 16:10:42 eric Exp $ */
+/* $OpenBSD: mta.c,v 1.186 2014/04/19 13:32:07 gilles Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
TAILQ_INSERT_TAIL(&relay->tasks, task, entry);
task->msgid = evpid_to_msgid(evp.id);
if (evp.sender.user[0] || evp.sender.domain[0])
- snprintf(buf, sizeof buf, "%s@%s",
+ (void)snprintf(buf, sizeof buf, "%s@%s",
evp.sender.user, evp.sender.domain);
else
buf[0] = '\0';
e = xcalloc(1, sizeof *e, "mta_envelope");
e->id = evp.id;
e->creation = evp.creation;
- snprintf(buf, sizeof buf, "%s@%s",
+ (void)snprintf(buf, sizeof buf, "%s@%s",
evp.dest.user, evp.dest.domain);
e->dest = xstrdup(buf, "mta_envelope:dest");
- snprintf(buf, sizeof buf, "%s@%s",
+ (void)snprintf(buf, sizeof buf, "%s@%s",
evp.rcpt.user, evp.rcpt.domain);
if (strcmp(buf, e->dest))
e->rcpt = xstrdup(buf, "mta_envelope:rcpt");
e->task = task;
if (evp.dsn_orcpt.user[0] && evp.dsn_orcpt.domain[0]) {
- snprintf(buf, sizeof buf, "%s@%s",
+ (void)snprintf(buf, sizeof buf, "%s@%s",
evp.dsn_orcpt.user, evp.dsn_orcpt.domain);
e->dsn_orcpt = xstrdup(buf,
"mta_envelope:dsn_orcpt");
}
- strlcpy(e->dsn_envid, evp.dsn_envid,
+ (void)strlcpy(e->dsn_envid, evp.dsn_envid,
sizeof e->dsn_envid);
e->dsn_notify = evp.dsn_notify;
e->dsn_ret = evp.dsn_ret;
case IMSG_CTL_MTA_SHOW_HOSTS:
t = time(NULL);
SPLAY_FOREACH(host, mta_host_tree, &hosts) {
- snprintf(buf, sizeof(buf),
+ (void)snprintf(buf, sizeof(buf),
"%s %s refcount=%d nconn=%zu lastconn=%s",
sockaddr_to_text(host->sa),
host->ptrname,
case IMSG_CTL_MTA_SHOW_ROUTES:
SPLAY_FOREACH(route, mta_route_tree, &routes) {
v = runq_pending(runq_route, NULL, route, &t);
- snprintf(buf, sizeof(buf),
+ (void)snprintf(buf, sizeof(buf),
"%llu. %s %c%c%c%c nconn=%zu nerror=%d penalty=%d timeout=%s",
(unsigned long long)route->id,
mta_route_to_text(route),
iter = NULL;
while (dict_iter(&hoststat, &iter, &hostname,
(void **)&hs)) {
- snprintf(buf, sizeof(buf),
+ (void)snprintf(buf, sizeof(buf),
"%s|%llu|%s",
hostname, (unsigned long long) hs->tm,
hs->error);
m_end(&m);
source = mta_source((struct sockaddr*)&ss);
if (strlen(dom)) {
- strlcpy(buf, dom, sizeof(buf));
- mta_block(source, buf);
+ if (!(strlcpy(buf, dom, sizeof(buf))
+ >= sizeof(buf)))
+ mta_block(source, buf);
}
else
mta_block(source, NULL);
m_end(&m);
source = mta_source((struct sockaddr*)&ss);
if (strlen(dom)) {
- strlcpy(buf, dom, sizeof(buf));
- mta_unblock(source, buf);
+ if (!(strlcpy(buf, dom, sizeof(buf))
+ >= sizeof(buf)))
+ mta_unblock(source, buf);
}
else
mta_unblock(source, NULL);
case IMSG_CTL_MTA_SHOW_BLOCK:
SPLAY_FOREACH(block, mta_block_tree, &blocks) {
- snprintf(buf, sizeof(buf), "%s -> %s",
+ (void)snprintf(buf, sizeof(buf), "%s -> %s",
mta_source_to_text(block->source),
block->domain ? block->domain : "*");
m_compose(p, IMSG_CTL_MTA_SHOW_BLOCK,
e->delivery = delivery;
if (status)
- strlcpy(e->status, status, sizeof(e->status));
+ (void)strlcpy(e->status, status, sizeof(e->status));
}
void
if (r->status & RELAY_WAITMASK) {
buf[0] = '\0';
if (r->status & RELAY_WAIT_MX)
- strlcat(buf, " MX", sizeof buf);
+ (void)strlcat(buf, " MX", sizeof buf);
if (r->status & RELAY_WAIT_PREFERENCE)
- strlcat(buf, " preference", sizeof buf);
+ (void)strlcat(buf, " preference", sizeof buf);
if (r->status & RELAY_WAIT_SECRET)
- strlcat(buf, " secret", sizeof buf);
+ (void)strlcat(buf, " secret", sizeof buf);
if (r->status & RELAY_WAIT_SOURCE)
- strlcat(buf, " source", sizeof buf);
+ (void)strlcat(buf, " source", sizeof buf);
if (r->status & RELAY_WAIT_CONNECTOR)
- strlcat(buf, " connector", sizeof buf);
+ (void)strlcat(buf, " connector", sizeof buf);
log_debug("debug: mta: %s waiting for%s",
mta_relay_to_text(r), buf);
return;
char tmp[32];
const char *sep = ",";
- snprintf(buf, sizeof buf, "[relay:%s", relay->domain->name);
+ (void)snprintf(buf, sizeof buf, "[relay:%s", relay->domain->name);
if (relay->port) {
- strlcat(buf, sep, sizeof buf);
- snprintf(tmp, sizeof tmp, "port=%d", (int)relay->port);
- strlcat(buf, tmp, sizeof buf);
+ (void)strlcat(buf, sep, sizeof buf);
+ (void)snprintf(tmp, sizeof tmp, "port=%d", (int)relay->port);
+ (void)strlcat(buf, tmp, sizeof buf);
}
if (relay->flags & RELAY_STARTTLS) {
- strlcat(buf, sep, sizeof buf);
- strlcat(buf, "starttls", sizeof buf);
+ (void)strlcat(buf, sep, sizeof buf);
+ (void)strlcat(buf, "starttls", sizeof buf);
}
if (relay->flags & RELAY_SMTPS) {
- strlcat(buf, sep, sizeof buf);
- strlcat(buf, "smtps", sizeof buf);
+ (void)strlcat(buf, sep, sizeof buf);
+ (void)strlcat(buf, "smtps", sizeof buf);
}
if (relay->flags & RELAY_AUTH) {
- strlcat(buf, sep, sizeof buf);
- strlcat(buf, "auth=", sizeof buf);
- strlcat(buf, relay->authtable, sizeof buf);
- strlcat(buf, ":", sizeof buf);
- strlcat(buf, relay->authlabel, sizeof buf);
+ (void)strlcat(buf, sep, sizeof buf);
+ (void)strlcat(buf, "auth=", sizeof buf);
+ (void)strlcat(buf, relay->authtable, sizeof buf);
+ (void)strlcat(buf, ":", sizeof buf);
+ (void)strlcat(buf, relay->authlabel, sizeof buf);
}
if (relay->pki_name) {
- strlcat(buf, sep, sizeof buf);
- strlcat(buf, "pki_name=", sizeof buf);
- strlcat(buf, relay->pki_name, sizeof buf);
+ (void)strlcat(buf, sep, sizeof buf);
+ (void)strlcat(buf, "pki_name=", sizeof buf);
+ (void)strlcat(buf, relay->pki_name, sizeof buf);
}
if (relay->flags & RELAY_MX) {
- strlcat(buf, sep, sizeof buf);
- strlcat(buf, "mx", sizeof buf);
+ (void)strlcat(buf, sep, sizeof buf);
+ (void)strlcat(buf, "mx", sizeof buf);
}
if (relay->backupname) {
- strlcat(buf, sep, sizeof buf);
- strlcat(buf, "backup=", sizeof buf);
- strlcat(buf, relay->backupname, sizeof buf);
+ (void)strlcat(buf, sep, sizeof buf);
+ (void)strlcat(buf, "backup=", sizeof buf);
+ (void)strlcat(buf, relay->backupname, sizeof buf);
}
if (relay->sourcetable) {
- strlcat(buf, sep, sizeof buf);
- strlcat(buf, "sourcetable=", sizeof buf);
- strlcat(buf, relay->sourcetable, sizeof buf);
+ (void)strlcat(buf, sep, sizeof buf);
+ (void)strlcat(buf, "sourcetable=", sizeof buf);
+ (void)strlcat(buf, relay->sourcetable, sizeof buf);
}
if (relay->helotable) {
- strlcat(buf, sep, sizeof buf);
- strlcat(buf, "helotable=", sizeof buf);
- strlcat(buf, relay->helotable, sizeof buf);
+ (void)strlcat(buf, sep, sizeof buf);
+ (void)strlcat(buf, "helotable=", sizeof buf);
+ (void)strlcat(buf, relay->helotable, sizeof buf);
}
if (relay->heloname) {
- strlcat(buf, sep, sizeof buf);
- strlcat(buf, "heloname=", sizeof buf);
- strlcat(buf, relay->heloname, sizeof buf);
+ (void)strlcat(buf, sep, sizeof buf);
+ (void)strlcat(buf, "heloname=", sizeof buf);
+ (void)strlcat(buf, relay->heloname, sizeof buf);
}
- strlcat(buf, "]", sizeof buf);
+ (void)strlcat(buf, "]", sizeof buf);
return (buf);
}
flags[0] = '\0';
-#define SHOWSTATUS(f, n) do { \
- if (r->status & (f)) { \
- if (flags[0]) \
- strlcat(flags, ",", sizeof(flags)); \
- strlcat(flags, (n), sizeof(flags)); \
- } \
+#define SHOWSTATUS(f, n) do { \
+ if (r->status & (f)) { \
+ if (flags[0]) \
+ (void)strlcat(flags, ",", sizeof(flags)); \
+ (void)strlcat(flags, (n), sizeof(flags)); \
+ } \
} while(0)
SHOWSTATUS(RELAY_WAIT_MX, "MX");
#undef SHOWSTATUS
if (runq_pending(runq_relay, NULL, r, &to))
- snprintf(dur, sizeof(dur), "%s", duration_to_text(to - t));
+ (void)snprintf(dur, sizeof(dur), "%s", duration_to_text(to - t));
else
- strlcpy(dur, "-", sizeof(dur));
+ (void)strlcpy(dur, "-", sizeof(dur));
- snprintf(buf, sizeof(buf), "%s refcount=%d ntask=%zu nconn=%zu lastconn=%s timeout=%s wait=%s%s",
+ (void)snprintf(buf, sizeof(buf), "%s refcount=%d ntask=%zu nconn=%zu lastconn=%s timeout=%s wait=%s%s",
mta_relay_to_text(r),
r->refcount,
r->ntask,
while (tree_iter(&r->connectors, &iter, NULL, (void **)&c)) {
if (runq_pending(runq_connector, NULL, c, &to))
- snprintf(dur, sizeof(dur), "%s", duration_to_text(to - t));
+ (void)snprintf(dur, sizeof(dur), "%s", duration_to_text(to - t));
else
- strlcpy(dur, "-", sizeof(dur));
+ (void)strlcpy(dur, "-", sizeof(dur));
flags[0] = '\0';
-#define SHOWFLAG(f, n) do { \
- if (c->flags & (f)) { \
- if (flags[0]) \
- strlcat(flags, ",", sizeof(flags)); \
- strlcat(flags, (n), sizeof(flags)); \
- } \
+#define SHOWFLAG(f, n) do { \
+ if (c->flags & (f)) { \
+ if (flags[0]) \
+ (void)strlcat(flags, ",", sizeof(flags)); \
+ (void)strlcat(flags, (n), sizeof(flags)); \
+ } \
} while(0)
SHOWFLAG(CONNECTOR_NEW, "NEW");
SHOWFLAG(CONNECTOR_LIMIT_DOMAIN, "LIMIT_DOMAIN");
#undef SHOWFLAG
- snprintf(buf, sizeof(buf),
+ (void)snprintf(buf, sizeof(buf),
" connector %s refcount=%d nconn=%zu lastconn=%s timeout=%s flags=%s",
mta_source_to_text(c->source),
c->refcount,
static char buf[1024];
if (h->ptrname)
- snprintf(buf, sizeof buf, "%s (%s)",
+ (void)snprintf(buf, sizeof buf, "%s (%s)",
sa_to_text(h->sa), h->ptrname);
else
- snprintf(buf, sizeof buf, "%s", sa_to_text(h->sa));
+ (void)snprintf(buf, sizeof buf, "%s", sa_to_text(h->sa));
return (buf);
}
if (s->sa == NULL)
return "[]";
- snprintf(buf, sizeof buf, "%s", sa_to_text(s->sa));
+ (void)snprintf(buf, sizeof buf, "%s", sa_to_text(s->sa));
return (buf);
}
{
static char buf[1024];
- snprintf(buf, sizeof buf, "[connector:%s->%s,0x%x]",
+ (void)snprintf(buf, sizeof buf, "[connector:%s->%s,0x%x]",
mta_source_to_text(c->source),
mta_relay_to_text(c->relay),
c->flags);
{
static char buf[1024];
- snprintf(buf, sizeof buf, "%s <-> %s",
+ (void)snprintf(buf, sizeof buf, "%s <-> %s",
mta_source_to_text(r->src),
mta_host_to_text(r->dst));
tree_init(&hs->deferred);
runq_schedule(runq_hoststat, tm+HOSTSTAT_EXPIRE_DELAY, NULL, hs);
}
- strlcpy(hs->name, buf, sizeof hs->name);
- strlcpy(hs->error, error, sizeof hs->error);
+ (void)strlcpy(hs->name, buf, sizeof hs->name);
+ (void)strlcpy(hs->error, error, sizeof hs->error);
hs->tm = time(NULL);
dict_set(&hoststat, buf, hs);