summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog2
-rw-r--r--openbsd-compat/setproctitle.c6
2 files changed, 7 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 684675ca6..7513c3d50 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,8 @@
2 - (dtucker) [openbsd-compat/bsd-misc.c] Include time.h for nanosleep. 2 - (dtucker) [openbsd-compat/bsd-misc.c] Include time.h for nanosleep.
3 From OpenSMTPD where it prevents "implicit declaration" warnings (it's 3 From OpenSMTPD where it prevents "implicit declaration" warnings (it's
4 a no-op in OpenSSH). From chl at openbsd. 4 a no-op in OpenSSH). From chl at openbsd.
5 - (dtucker) [openbsd-compat/setproctitle.c] Handle error case form the 2nd
6 vsnprintf. From eric at openbsd via chl@.
5 7
620131030 820131030
7 - (djm) OpenBSD CVS Sync 9 - (djm) OpenBSD CVS Sync
diff --git a/openbsd-compat/setproctitle.c b/openbsd-compat/setproctitle.c
index 2965f689e..a69db22a2 100644
--- a/openbsd-compat/setproctitle.c
+++ b/openbsd-compat/setproctitle.c
@@ -125,6 +125,7 @@ setproctitle(const char *fmt, ...)
125 va_list ap; 125 va_list ap;
126 char buf[1024], ptitle[1024]; 126 char buf[1024], ptitle[1024];
127 size_t len; 127 size_t len;
128 int r;
128 extern char *__progname; 129 extern char *__progname;
129#if SPT_TYPE == SPT_PSTAT 130#if SPT_TYPE == SPT_PSTAT
130 union pstun pst; 131 union pstun pst;
@@ -137,13 +138,16 @@ setproctitle(const char *fmt, ...)
137 138
138 strlcpy(buf, __progname, sizeof(buf)); 139 strlcpy(buf, __progname, sizeof(buf));
139 140
141 r = -1;
140 va_start(ap, fmt); 142 va_start(ap, fmt);
141 if (fmt != NULL) { 143 if (fmt != NULL) {
142 len = strlcat(buf, ": ", sizeof(buf)); 144 len = strlcat(buf, ": ", sizeof(buf));
143 if (len < sizeof(buf)) 145 if (len < sizeof(buf))
144 vsnprintf(buf + len, sizeof(buf) - len , fmt, ap); 146 r = vsnprintf(buf + len, sizeof(buf) - len , fmt, ap);
145 } 147 }
146 va_end(ap); 148 va_end(ap);
149 if (r == -1 || (size_t)r >= sizeof(buf) - len)
150 return;
147 strnvis(ptitle, buf, sizeof(ptitle), 151 strnvis(ptitle, buf, sizeof(ptitle),
148 VIS_CSTYLE|VIS_NL|VIS_TAB|VIS_OCTAL); 152 VIS_CSTYLE|VIS_NL|VIS_TAB|VIS_OCTAL);
149 153