Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stalld: Fix freeing of invalid pointer
If wrong regex is given, then while parsing regex we call cleanup_regex - parse_task_ignore_string() - compile_regex() - cleanup_regex() compiled = *compiled_expr; if (compiled) free(compiled); - we doesn't reset the *compiled_expr variable after freeing and it is extern variable - again cleanup_regex() gets called from stalld.c with already freed address(Non Null Address): - when we `systemctl restart stalld`, we get coredump: which shows systemd[1]: Stopping Stall Monitor... systemd-coredump[780991]: Process 780670 (stalld) of user 0 dumped core. Stack trace of thread 780670: #0 0x00007f6becf1e041 raise (libc.so.6 + 0x3d041) #1 0x00007f6becf07536 abort (libc.so.6 + 0x26536) #2 0x00007f6becf5f5a8 n/a (libc.so.6 + 0x7e5a8) #3 0x00007f6becf66fea n/a (libc.so.6 + 0x85fea) #4 0x00007f6becf673dc n/a (libc.so.6 + 0x863dc) #5 0x000055666563ed7e n/a (/usr/bin/stalld (deleted) + 0x6d7e) systemd[1]: stalld.service: Main process exited, code=dumped, status=6/ABRT systemd[1]: stalld.service: Failed with result 'core-dump' - Resetting the extern variable to NULL after freeing the memory solves this issue. Change-Id: Ia6bae7379970b5633194619d00c1d19adea120c2 Signed-off-by: Ankit Jain <ankitja@vmware.com> Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/19968 Tested-by: gerrit-photon <photon-checkins@vmware.com> Reviewed-by: Srivatsa S. Bhat <srivatsab@vmware.com>
- Loading branch information