From fb531d31240229fc86b0a98b0fa026e5dac2fda3 Mon Sep 17 00:00:00 2001 From: anton Date: Sat, 27 Jan 2018 08:32:03 +0000 Subject: [PATCH] Avoid passing NULL to vprintf() by assigning a name to client processes. While here rework the switch proc_title(), both clang and gcc will now warn if all possible values are not enumerated. ok gilles@ --- usr.sbin/smtpd/control.c | 4 +++- usr.sbin/smtpd/smtpd.c | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/usr.sbin/smtpd/control.c b/usr.sbin/smtpd/control.c index b1123e6428b..d3e5b693680 100644 --- a/usr.sbin/smtpd/control.c +++ b/usr.sbin/smtpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.120 2017/11/27 08:35:59 sunil Exp $ */ +/* $OpenBSD: control.c,v 1.121 2018/01/27 08:32:03 anton Exp $ */ /* * Copyright (c) 2012 Gilles Chehade @@ -336,6 +336,8 @@ control_accept(int listenfd, short event, void *arg) c->mproc.proc = PROC_CLIENT; c->mproc.handler = control_dispatch_ext; c->mproc.data = c; + if ((c->mproc.name = strdup(proc_title(c->mproc.proc))) == NULL) + fatal("strdup"); mproc_init(&c->mproc, connfd); mproc_enable(&c->mproc); tree_xset(&ctl_conns, c->id, c); diff --git a/usr.sbin/smtpd/smtpd.c b/usr.sbin/smtpd/smtpd.c index 03c2f803e0d..5ca0499028d 100644 --- a/usr.sbin/smtpd/smtpd.c +++ b/usr.sbin/smtpd/smtpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.c,v 1.291 2017/11/21 12:20:34 eric Exp $ */ +/* $OpenBSD: smtpd.c,v 1.292 2018/01/27 08:32:03 anton Exp $ */ /* * Copyright (c) 2008 Gilles Chehade @@ -1663,9 +1663,10 @@ proc_title(enum smtp_proc_type proc) return "pony express"; case PROC_CA: return "klondike"; - default: - return "unknown"; + case PROC_CLIENT: + return "client"; } + return "unknown"; } const char * -- 2.20.1