Package: opensmtpd
Version: 5.3.3p1-3
Tags: upstream

re: https://github.com/poolpOrg/OpenSMTPD/issues/239

I see now.  The git tree I cloned from github has no openbsd-compat
sub-directory. It's unfortunate that the closed tickets don't have
links to the commits.

I'll give this a try later.

On Sun, Sep 22, 2013 at 10:23 AM, Ryan Kavanagh <r...@debian.org> wrote:

> Thanks for the email. I suspect this is the relevant commit. I'll try to
> test it / upload a fixed package in the next few days.

>From 1bf55e2711b8f1575c8d4775002c3035f13a99a7 Mon Sep 17 00:00:00 2001
From: Eric Faurot <e...@faurot.net>
Date: Fri, 7 Jun 2013 15:56:59 +0200
Subject: [PATCH] setproctile() tweakery alters memory buffer referenced by
 __progname, which make the logs look bad.  Set __progname to a safe static
 buffer early on to make everybody happy.  While there, check for overflow to
 make gilles happy.

---
 openbsd-compat/setproctitle.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/openbsd-compat/setproctitle.c b/openbsd-compat/setproctitle.c
index 2965f68..ae3d92c 100644
--- a/openbsd-compat/setproctitle.c
+++ b/openbsd-compat/setproctitle.c
@@ -64,6 +64,9 @@ static size_t argv_env_len = 0;

 #endif /* HAVE_SETPROCTITLE */

+static char altprogname[1024];
+extern char *__progname;
+
 void
 compat_init_setproctitle(int argc, char *argv[])
 {
@@ -73,6 +76,9 @@ compat_init_setproctitle(int argc, char *argv[])
        char **envp = environ;
        int i;

+       strlcpy(altprogname, __progname, sizeof(altprogname));
+       __progname = altprogname;
+
        /*
         * NB: This assumes that argv has already been copied out of the
         * way. This is true for sshd, but may not be true for other
@@ -125,7 +131,7 @@ setproctitle(const char *fmt, ...)
        va_list ap;
        char buf[1024], ptitle[1024];
        size_t len;
-       extern char *__progname;
+       int r;
 #if SPT_TYPE == SPT_PSTAT
        union pstun pst;
 #endif
@@ -137,13 +143,16 @@ setproctitle(const char *fmt, ...)

        strlcpy(buf, __progname, sizeof(buf));

+       r = -1;
        va_start(ap, fmt);
        if (fmt != NULL) {
                len = strlcat(buf, ": ", sizeof(buf));
                if (len < sizeof(buf))
-                       vsnprintf(buf + len, sizeof(buf) - len , fmt, ap);
+                       r = vsnprintf(buf + len, sizeof(buf) - len , fmt, ap);
        }
        va_end(ap);
+       if (r == -1 || (size_t)r >= sizeof(buf) - len)
+               return;
        strnvis(ptitle, buf, sizeof(ptitle),
            VIS_CSTYLE|VIS_NL|VIS_TAB|VIS_OCTAL);


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to