summaryrefslogtreecommitdiffstats
path: root/sys/fs/procfs/procfs_status.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/fs/procfs/procfs_status.c')
-rw-r--r--sys/fs/procfs/procfs_status.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/sys/fs/procfs/procfs_status.c b/sys/fs/procfs/procfs_status.c
index c75294b..1c8b4ca 100644
--- a/sys/fs/procfs/procfs_status.c
+++ b/sys/fs/procfs/procfs_status.c
@@ -69,7 +69,7 @@ procfs_dostatus(curp, p, pfs, uio)
struct session *sess;
struct tty *tp;
struct ucred *cr;
- char *ps;
+ char *ps, *pc;
char *sep;
int pid, ppid, pgid, sid;
int i;
@@ -95,10 +95,16 @@ procfs_dostatus(curp, p, pfs, uio)
("Too short buffer for new MAXCOMLEN"));
ps = psbuf;
- bcopy(p->p_comm, ps, MAXCOMLEN);
- ps[MAXCOMLEN] = '\0';
- ps += strlen(ps);
- DOCHECK();
+ pc = p->p_comm;
+ xlen = strlen(p->p_comm);
+ do {
+ if (*pc < 33 || *pc > 126 || *pc == '\\')
+ ps += snprintf(ps, psbuf + sizeof(psbuf) - ps, "\\%03o",
+ *pc);
+ else
+ *ps++ = *pc;
+ DOCHECK();
+ } while (++pc < p->p_comm + xlen);
ps += snprintf(ps, psbuf + sizeof(psbuf) - ps,
" %d %d %d %d ", pid, ppid, pgid, sid);
DOCHECK();
OpenPOWER on IntegriCloud