monitor: Add error handling codes 07/302807/3
authorSung-hun Kim <sfoon.kim@samsung.com>
Thu, 14 Dec 2023 01:49:34 +0000 (10:49 +0900)
committerSung-hun Kim <sfoon.kim@samsung.com>
Thu, 14 Dec 2023 02:58:58 +0000 (11:58 +0900)
commita4b7210e99dd65501e70203144cf34e08e7e7d56
treead4ab24b5a8527ae9c211b9a47c125a604fff51b
parentfd99f701e288e8240939b152ac340981c15f1143
monitor: Add error handling codes

Since the request-handler code does not handle error cases,
the pass daemon killed with segmentation fault.

See the below gdb output:

 Program terminated with signal SIGSEGV, Segmentation fault.
 #0  handle_request (client=client@entry=0x7f680008d0, request=request@entry=0x7f72ffc270 "17") at /usr/src/debug/pass-2.0.0-1.aarch64/src/monitor/request-handler.c:877
 877 /usr/src/debug/pass-2.0.0-1.aarch64/src/monitor/request-handler.c: No such file or directory.
 [Current thread is 1 (LWP 5465)]
 >>> bt
 #0  handle_request (client=client@entry=0x7f680008d0, request=request@entry=0x7f72ffc270 "17") at /usr/src/debug/pass-2.0.0-1.aarch64/src/monitor/request-handler.c:877
 #1  0x000000558df6eda0 in request_handler_func (data=0x7f680008d0, result=<optimized out>) at /usr/src/debug/pass-2.0.0-1.aarch64/src/monitor/request-handler.c:1012
 #2  0x000000558df5bb28 in __thread_loop_main (_ctx=0x7f68001170) at /usr/src/debug/pass-2.0.0-1.aarch64/src/util/thread.c:45
 #3  0x0000007f833b882c in ?? () from /lib64/libpthread.so.0
 #4  0x0000007f83319eac in thread_start () at ../sysdeps/unix/sysv/linux/aarch64/clone.S:78

I added an error handling code with NULL check for the variable
`array`.

Change-Id: I93bc4a23903c2c7d7fc9315d238d2c5addddc445
Signed-off-by: Sung-hun Kim <sfoon.kim@samsung.com>
src/monitor/request-handler.c