summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorEric Faurot <eric@cvs.openbsd.org>2018-11-11 14:00:52 +0000
committerEric Faurot <eric@cvs.openbsd.org>2018-11-11 14:00:52 +0000
commit3a8185313559d9610d7c4c256fefd5bf3fb64b49 (patch)
tree30a09f1eef6613e3d4fed5c92e420419ebee1700 /usr.sbin
parentfe78448c9547f8ef6a056e1fb897ee1461323db0 (diff)
accept NULL as a valid string in the proc message formating api.
ok gilles@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/smtpd/mproc.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/usr.sbin/smtpd/mproc.c b/usr.sbin/smtpd/mproc.c
index e50ca37d992..97da799b09f 100644
--- a/usr.sbin/smtpd/mproc.c
+++ b/usr.sbin/smtpd/mproc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mproc.c,v 1.29 2017/03/17 20:57:57 eric Exp $ */
+/* $OpenBSD: mproc.c,v 1.30 2018/11/11 14:00:51 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@faurot.net>
@@ -441,7 +441,12 @@ m_add_time(struct mproc *m, time_t v)
void
m_add_string(struct mproc *m, const char *v)
{
- m_add(m, v, strlen(v) + 1);
+ if (v) {
+ m_add(m, "s", 1);
+ m_add(m, v, strlen(v) + 1);
+ }
+ else
+ m_add(m, "\0", 1);
};
void
@@ -539,10 +544,19 @@ void
m_get_string(struct msg *m, const char **s)
{
uint8_t *end;
+ char c;
if (m->pos >= m->end)
m_error("msg too short");
+ c = *m->pos++;
+ if (c == '\0') {
+ *s = NULL;
+ return;
+ }
+
+ if (m->pos >= m->end)
+ m_error("msg too short");
end = memchr(m->pos, 0, m->end - m->pos);
if (end == NULL)
m_error("unterminated string");