- (dtucker) [openbsd-compat/setproctitle.c] Handle error case form the 2nd
vsnprintf. From eric at openbsd via chl@.
This commit is contained in:
parent
d527704523
commit
710f374735
|
@ -2,6 +2,8 @@
|
||||||
- (dtucker) [openbsd-compat/bsd-misc.c] Include time.h for nanosleep.
|
- (dtucker) [openbsd-compat/bsd-misc.c] Include time.h for nanosleep.
|
||||||
From OpenSMTPD where it prevents "implicit declaration" warnings (it's
|
From OpenSMTPD where it prevents "implicit declaration" warnings (it's
|
||||||
a no-op in OpenSSH). From chl at openbsd.
|
a no-op in OpenSSH). From chl at openbsd.
|
||||||
|
- (dtucker) [openbsd-compat/setproctitle.c] Handle error case form the 2nd
|
||||||
|
vsnprintf. From eric at openbsd via chl@.
|
||||||
|
|
||||||
20131030
|
20131030
|
||||||
- (djm) OpenBSD CVS Sync
|
- (djm) OpenBSD CVS Sync
|
||||||
|
|
|
@ -125,6 +125,7 @@ setproctitle(const char *fmt, ...)
|
||||||
va_list ap;
|
va_list ap;
|
||||||
char buf[1024], ptitle[1024];
|
char buf[1024], ptitle[1024];
|
||||||
size_t len;
|
size_t len;
|
||||||
|
int r;
|
||||||
extern char *__progname;
|
extern char *__progname;
|
||||||
#if SPT_TYPE == SPT_PSTAT
|
#if SPT_TYPE == SPT_PSTAT
|
||||||
union pstun pst;
|
union pstun pst;
|
||||||
|
@ -137,13 +138,16 @@ setproctitle(const char *fmt, ...)
|
||||||
|
|
||||||
strlcpy(buf, __progname, sizeof(buf));
|
strlcpy(buf, __progname, sizeof(buf));
|
||||||
|
|
||||||
|
r = -1;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
if (fmt != NULL) {
|
if (fmt != NULL) {
|
||||||
len = strlcat(buf, ": ", sizeof(buf));
|
len = strlcat(buf, ": ", sizeof(buf));
|
||||||
if (len < 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);
|
va_end(ap);
|
||||||
|
if (r == -1 || (size_t)r >= sizeof(buf) - len)
|
||||||
|
return;
|
||||||
strnvis(ptitle, buf, sizeof(ptitle),
|
strnvis(ptitle, buf, sizeof(ptitle),
|
||||||
VIS_CSTYLE|VIS_NL|VIS_TAB|VIS_OCTAL);
|
VIS_CSTYLE|VIS_NL|VIS_TAB|VIS_OCTAL);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue