diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2003-04-15 01:19:35 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2003-04-15 01:19:35 +0000 |
commit | add4e4e87558f04377e5ad1407d059a0948d2fd5 (patch) | |
tree | 3c939eec45ac6f049e463cf8072b8d5d4f822979 /bin | |
parent | ab18176e944fd41f79842d864b42cfd2fefff1fd (diff) |
mix of tdeval and my string cleaning
Diffstat (limited to 'bin')
-rw-r--r-- | bin/ps/ps.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/bin/ps/ps.c b/bin/ps/ps.c index 822e43b1ea7..b9576c94f6e 100644 --- a/bin/ps/ps.c +++ b/bin/ps/ps.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ps.c,v 1.30 2002/06/12 03:44:35 art Exp $ */ +/* $OpenBSD: ps.c,v 1.31 2003/04/15 01:19:34 deraadt Exp $ */ /* $NetBSD: ps.c,v 1.15 1995/05/18 20:33:25 mycroft Exp $ */ /*- @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)ps.c 8.4 (Berkeley) 4/2/94"; #else -static char rcsid[] = "$OpenBSD: ps.c,v 1.30 2002/06/12 03:44:35 art Exp $"; +static char rcsid[] = "$OpenBSD: ps.c,v 1.31 2003/04/15 01:19:34 deraadt Exp $"; #endif #endif /* not lint */ @@ -463,13 +463,14 @@ kludge_oldps_options(s) char *newopts, *ns, *cp; len = strlen(s); - if ((newopts = ns = malloc(len + 3)) == NULL) + if ((newopts = ns = malloc(2 + len + 1)) == NULL) err(1, NULL); /* * options begin with '-' */ if (*s != '-') *ns++ = '-'; /* add option flag */ + /* * gaze to end of argv[1] */ @@ -499,7 +500,8 @@ kludge_oldps_options(s) if (isdigit(*cp) && (cp == s || (cp[-1] != 't' && cp[-1] != 'p' && (cp - 1 == s || cp[-2] != 't')))) *ns++ = 'p'; - (void)strcpy(ns, cp); /* and append the number */ + /* and append the number */ + (void)strlcpy(ns, cp, newopts + len + 3 - ns); return (newopts); } |