From c5e7f73bc6708a8b6247c0b4a00e2b72b743c280 Mon Sep 17 00:00:00 2001 From: Jorge Lucangeli Obes Date: Mon, 25 Apr 2016 15:53:09 -0700 Subject: [PATCH] Fix 'ps --ppid'. Currently, 'ps' will segfault when called with '--ppid' and no argument. Make it return an error instead. Bug: 28383024 Change-Id: I71f2d1ba9502996ae75b17605234eb99ebb589f2 --- toolbox/ps.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/toolbox/ps.c b/toolbox/ps.c index d366f3ecf..633c48ea5 100644 --- a/toolbox/ps.c +++ b/toolbox/ps.c @@ -282,6 +282,13 @@ int ps_main(int argc, char **argv) } else if(!strcmp(argv[1],"--abi")) { display_flags |= SHOW_ABI; } else if(!strcmp(argv[1],"--ppid")) { + if (argc < 3) { + /* Bug 26554285: Use printf because some apps require at least + * one line of output to stdout even for errors. + */ + printf("no ppid\n"); + return 1; + } ppid_filter = atoi(argv[2]); if (ppid_filter == 0) { /* Bug 26554285: Use printf because some apps require at least