diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 2002-01-30 17:52:41 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 2002-01-30 17:52:41 +0000 |
commit | 3f6f4cddbfbd8741fd5f41b841a59c16728bafc1 (patch) | |
tree | 2e5ce4d943d6ae429ecdbeef22e77c9241ca6994 | |
parent | aa7bad31c0be209909d7d67e47d02a03e85dee89 (diff) |
right, just check more for nulls; from Dan Harnett <danh@wzrd.com>
-rw-r--r-- | bin/ps/print.c | 20 | ||||
-rw-r--r-- | bin/ps/ps.c | 8 |
2 files changed, 15 insertions, 13 deletions
diff --git a/bin/ps/print.c b/bin/ps/print.c index a52d9ebdeb8..9dcc4f7d386 100644 --- a/bin/ps/print.c +++ b/bin/ps/print.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print.c,v 1.22 2001/12/05 02:23:59 art Exp $ */ +/* $OpenBSD: print.c,v 1.23 2002/01/30 17:52:40 mickey Exp $ */ /* $NetBSD: print.c,v 1.27 1995/09/29 21:58:12 cgd Exp $ */ /*- @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94"; #else -static char rcsid[] = "$OpenBSD: print.c,v 1.22 2001/12/05 02:23:59 art Exp $"; +static char rcsid[] = "$OpenBSD: print.c,v 1.23 2002/01/30 17:52:40 mickey Exp $"; #endif #endif /* not lint */ @@ -123,7 +123,7 @@ command(ki, ve) left = v->width; } else left = -1; - if (needenv) { + if (needenv && kd != NULL) { argv = kvm_getenvv(kd, ki->ki_p, termwidth); if ((p = argv) != NULL) { while (*p) { @@ -135,12 +135,14 @@ command(ki, ve) } if (needcomm) { if (!commandonly) { - argv = kvm_getargv(kd, ki->ki_p, termwidth); - if ((p = argv) != NULL) { - while (*p) { - fmt_puts(*p, &left); - p++; - fmt_putc(' ', &left); + if (kd != NULL) { + argv = kvm_getargv(kd, ki->ki_p, termwidth); + if ((p = argv) != NULL) { + while (*p) { + fmt_puts(*p, &left); + p++; + fmt_putc(' ', &left); + } } } if (argv == 0 || argv[0] == 0 || diff --git a/bin/ps/ps.c b/bin/ps/ps.c index 2ec97eff64f..16cea0d3162 100644 --- a/bin/ps/ps.c +++ b/bin/ps/ps.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ps.c,v 1.24 2002/01/30 17:02:55 mickey Exp $ */ +/* $OpenBSD: ps.c,v 1.25 2002/01/30 17:52:40 mickey 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.24 2002/01/30 17:02:55 mickey Exp $"; +static char rcsid[] = "$OpenBSD: ps.c,v 1.25 2002/01/30 17:52:40 mickey Exp $"; #endif #endif /* not lint */ @@ -286,7 +286,7 @@ main(argc, argv) } kd = kvm_openfiles(nlistf, memf, swapf, O_RDONLY, errbuf); - if (kd == NULL) + if (kd == NULL && (nlistf != NULL || memf != NULL || swapf != NULL)) errx(1, "%s", errbuf); setegid(getgid()); @@ -420,7 +420,7 @@ saveuser(ki) struct usave *usp; usp = &ki->ki_u; - if (kvm_read(kd, (u_long)&KI_PROC(ki)->p_addr->u_stats, + if (kd != NULL && kvm_read(kd, (u_long)&KI_PROC(ki)->p_addr->u_stats, &pstats, sizeof(pstats)) == sizeof(pstats)) { /* * The u-area might be swapped out, and we can't get |