fixed setuid() / setgid() ordering (#517)

This commit is contained in:
Fabrice Bellard 2026-06-01 18:47:42 +02:00
parent e6c2be818a
commit 4a13c45081

@ -3305,14 +3305,14 @@ static JSValue js_os_exec(JSContext *ctx, JSValueConst this_val,
if (chdir(cwd) < 0)
_exit(127);
}
if (uid != -1) {
if (setuid(uid) < 0)
_exit(127);
}
if (gid != -1) {
if (setgid(gid) < 0)
_exit(127);
}
if (uid != -1) {
if (setuid(uid) < 0)
_exit(127);
}
if (!file)
file = exec_argv[0];