diff options
author | Damien Miller <djm@mindrot.org> | 2008-05-16 10:01:54 +1000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2008-05-16 10:01:54 +1000 |
commit | c5750226af60d321f11eea8c316c958048ee000d (patch) | |
tree | 97bd83dfa22f2bd6aa97ab3668c150ebaf5838df /openbsd-compat/setproctitle.c | |
parent | 55754fb0024cb84f99a72e15196fa03456a0c097 (diff) |
- (djm) Force string arguments to replacement setproctitle() though
strnvis first. Ok dtucker@
Diffstat (limited to 'openbsd-compat/setproctitle.c')
-rw-r--r-- | openbsd-compat/setproctitle.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/openbsd-compat/setproctitle.c b/openbsd-compat/setproctitle.c index b511f664..2965f689 100644 --- a/openbsd-compat/setproctitle.c +++ b/openbsd-compat/setproctitle.c @@ -43,6 +43,8 @@ #endif #include <string.h> +#include <vis.h> + #define SPT_NONE 0 /* don't use it at all */ #define SPT_PSTAT 1 /* use pstat(PSTAT_SETCMD, ...) */ #define SPT_REUSEARGV 2 /* cover argv with title information */ @@ -121,7 +123,7 @@ setproctitle(const char *fmt, ...) { #if SPT_TYPE != SPT_NONE va_list ap; - char buf[1024]; + char buf[1024], ptitle[1024]; size_t len; extern char *__progname; #if SPT_TYPE == SPT_PSTAT @@ -142,14 +144,16 @@ setproctitle(const char *fmt, ...) vsnprintf(buf + len, sizeof(buf) - len , fmt, ap); } va_end(ap); + strnvis(ptitle, buf, sizeof(ptitle), + VIS_CSTYLE|VIS_NL|VIS_TAB|VIS_OCTAL); #if SPT_TYPE == SPT_PSTAT - pst.pst_command = buf; - pstat(PSTAT_SETCMD, pst, strlen(buf), 0, 0); + pst.pst_command = ptitle; + pstat(PSTAT_SETCMD, pst, strlen(ptitle), 0, 0); #elif SPT_TYPE == SPT_REUSEARGV /* debug("setproctitle: copy \"%s\" into len %d", buf, argv_env_len); */ - len = strlcpy(argv_start, buf, argv_env_len); + len = strlcpy(argv_start, ptitle, argv_env_len); for(; len < argv_env_len; len++) argv_start[len] = SPT_PADCHAR; #endif |