[PAL/{Linux/FreeBSD}] Handle failure on child process creation in DkProcessCreate()

This commit is contained in:
Gary
2019-05-15 13:41:00 -07:00
committed by Dmitrii Kuvaiskii
parent d357ab9a26
commit bc0ddb282b
2 changed files with 6 additions and 14 deletions
+3 -4
View File
@@ -152,8 +152,7 @@ static int child_process (void * param)
failed:
/* fail is it gets here */
_DkThreadExit();
return 0;
return -PAL_ERROR_DENIED;
}
int _DkProcessCreate (PAL_HANDLE * handle, const char * uri, const char ** args)
@@ -267,8 +266,8 @@ int _DkProcessCreate (PAL_HANDLE * handle, const char * uri, const char ** args)
}
if (!ret) {
child_process(&param);
return 0;
ret = child_process(&param);
goto out; /* if child_process returned, there was a failure */
}
child_handle->process.pid = ret;
+3 -10
View File
@@ -157,11 +157,10 @@ static int child_process (void * param)
INLINE_SYSCALL(execve, 3, PAL_LOADER, proc_param->argv,
linux_state.environ);
ret = -PAL_ERROR_DENIED;
failed:
/* fail is it gets here */
return ret;
return -PAL_ERROR_DENIED;
}
int _DkProcessCreate (PAL_HANDLE * handle, const char * uri, const char ** args)
@@ -291,7 +290,6 @@ int _DkProcessCreate (PAL_HANDLE * handle, const char * uri, const char ** args)
#endif
ret = ARCH_VFORK();
int child_ret = 0;
if (IS_ERR(ret)) {
ret = -PAL_ERROR_DENIED;
@@ -299,13 +297,8 @@ int _DkProcessCreate (PAL_HANDLE * handle, const char * uri, const char ** args)
}
if (!ret) {
child_ret = child_process(&param);
return 0;
}
if (child_ret < 0) {
ret = child_ret;
goto out;
ret = child_process(&param);
goto out; /* if child_process returned, there was a failure */
}
proc_args->pal_sec.process_id = ret;