From: Daniel Golle Date: Fri, 16 Oct 2020 02:24:17 +0000 (+0100) Subject: mount: restorecon: guard against execl() errors X-Git-Url: http://git.openwrt.org/?p=project%2Ffstools.git;a=commitdiff_plain;h=48625308a375a3d3e08446661491a8dd1fbf172d mount: restorecon: guard against execl() errors In the current implementation, in case of execl("/sbin/restorecon") failing, the child process will also return and that will lead to even more disasterous effects. Though it seems unlikely that execl() would fail given that the file exists, simply catch that case by exiting in case execl() returns. Signed-off-by: Daniel Golle --- diff --git a/libfstools/mount.c b/libfstools/mount.c index b30e5a6..1691ce7 100644 --- a/libfstools/mount.c +++ b/libfstools/mount.c @@ -99,7 +99,7 @@ selinux_restorecon(char *overlaydir) restorecon_pid = fork(); if (!restorecon_pid) - execl("/sbin/restorecon", "restorecon", overlaydir, (char *) NULL); + exit(execl("/sbin/restorecon", "restorecon", overlaydir, (char *) NULL)); else if (restorecon_pid > 0) waitpid(restorecon_pid, &status, 0); }