add a file type check to exec()

This commit is contained in:
Lisa Milne 2023-12-03 16:27:33 +10:00
parent 0a9e229841
commit 755c79dd46
2 changed files with 7 additions and 2 deletions

View file

@ -2253,7 +2253,12 @@ clite.lib = {
if (!fd.canexec) {
clite.io.close(io.pid,fd);
return -3
return -3;
}
if (clite.lib.getFileType(fd) != clite.io.types.FT_BINARY) {
clite.io.close(io.pid,fd);
return -4;
}
clite.proc.update(args.join(' '));

View file

@ -312,7 +312,7 @@ clite.commands.load('sh',function(args,env,io) {
io.exit(-1);
}
if (r == -3) {
if (r == -3 || r == -4) {
stdio.write(io.stderr,'Shell: not an executable file:'+args[0]);
io.exit(-3);
}