From 68bd42fb10cfaf278e841d2925da7f061820abd4 Mon Sep 17 00:00:00 2001
From: xuchunmei <xuchunmei@huawei.com>
Date: Wed, 23 Jan 2019 07:57:53 -0500
Subject: [PATCH] top: exit with error when pid overflow

Signed-off-by: xuchunmei <xuchunmei@huawei.com>
Signed-off-by: Qiang Wei <qiang.wei@suse.com>
---
 top/top.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/src/top/top.c
+++ b/src/top/top.c
@@ -4338,7 +4338,8 @@ static void parse_args (int argc, char *
                if (Monpidsidx >= MONPIDMAX)
                   error_exit(fmtmk(N_fmt(LIMIT_exceed_fmt), MONPIDMAX));
                if (1 != sscanf(cp, "%d", &pid)
-               || strpbrk(cp, "+-."))
+               || strpbrk(cp, "+-.")
+	        || 0 > pid)
                   error_exit(fmtmk(N_fmt(BAD_mon_pids_fmt), cp));
                if (!pid) pid = getpid();
                for (i = 0; i < Monpidsidx; i++)
