diff options
author | Dongwoo Lee <dwoo08.lee@samsung.com> | 2022-08-25 14:47:00 +0900 |
---|---|---|
committer | Chanwoo Choi <cw00.choi@samsung.com> | 2022-08-30 11:30:32 +0900 |
commit | e0ddc6052379632e003bfab2b3f685695adcd259 (patch) | |
tree | 52f880baee86e552c3e43b663788a9ce180af0f7 | |
parent | ff38f3e0c117e9e55f12e01e89c52f6dfd2c7682 (diff) | |
download | pass-e0ddc6052379632e003bfab2b3f685695adcd259.tar.gz pass-e0ddc6052379632e003bfab2b3f685695adcd259.tar.bz2 pass-e0ddc6052379632e003bfab2b3f685695adcd259.zip |
tools: resource-monitor: Check validation of '-n' option argumentsubmit/tizen/20220830.030501
Change-Id: I28dc6a85d44455043a56c49bdee824d2590757c0
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
-rw-r--r-- | tools/resource-monitor/resource-monitor.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/tools/resource-monitor/resource-monitor.c b/tools/resource-monitor/resource-monitor.c index 90dfce9..ebb64f4 100644 --- a/tools/resource-monitor/resource-monitor.c +++ b/tools/resource-monitor/resource-monitor.c @@ -177,8 +177,8 @@ struct resource_data { struct resource_monitor_data { unsigned int pid; unsigned int ppid; - unsigned int secs; - unsigned int max; + int secs; + int max; int mon_id; int num_res; @@ -562,12 +562,20 @@ int main(int argc, char *argv[]) g_data.ppid = atoi(argv[opt + 1]); } else if (!strncmp(argv[opt], "-", 1)) { for (i = 1; *(argv[opt] + i); i++) { + int input; + switch (*(argv[opt] + i)) { case 'd': - g_data.secs = atoi(argv[opt + 1]); + input = atoi(argv[opt + 1]); + if (input < 0 || input >= INT_MAX) + break; + g_data.secs = input; break; case 'n': - g_data.max = atoi(argv[opt + 1]); + input = atoi(argv[opt + 1]); + if (input < 0 || input >= INT_MAX) + break; + g_data.max = input; break; case 'p': g_data.pid = atoi(argv[opt + 1]); |