diff options
author | Darren Tucker <dtucker@zip.com.au> | 2013-11-03 17:20:34 +1100 |
---|---|---|
committer | Darren Tucker <dtucker@zip.com.au> | 2013-11-03 17:20:34 +1100 |
commit | 710f3747352fb93a63e5b69b12379da37f5b3fa9 (patch) | |
tree | c3c72c89163211a54b74fd76cf4754bb13abc6c5 /openbsd-compat/setproctitle.c | |
parent | d52770452308e5c2e99f4da6edaaa77ef078b610 (diff) |
- (dtucker) [openbsd-compat/setproctitle.c] Handle error case form the 2nd
vsnprintf. From eric at openbsd via chl@.
Diffstat (limited to 'openbsd-compat/setproctitle.c')
-rw-r--r-- | openbsd-compat/setproctitle.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/openbsd-compat/setproctitle.c b/openbsd-compat/setproctitle.c index 2965f689..a69db22a 100644 --- a/openbsd-compat/setproctitle.c +++ b/openbsd-compat/setproctitle.c @@ -125,6 +125,7 @@ setproctitle(const char *fmt, ...) va_list ap; char buf[1024], ptitle[1024]; size_t len; + int r; extern char *__progname; #if SPT_TYPE == SPT_PSTAT union pstun pst; @@ -137,13 +138,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); |