[patch] prevent ash executing non-files
Rob Landley
rob at landley.net
Sun Sep 10 18:35:02 UTC 2006
On Sunday 10 September 2006 11:14 am, walter harms wrote:
> hi list,
> while testing i noticed that ash happy executed non-regular
> files like / even returning success. this patch will prevent
> that. it used stat() to find the type and errors anything that
> is not a file.
> btw: links do still work. i tested it.
The way bbsh is handling this is to return error code 127 when the exec fails,
which it does if you try to exec "/", as demonstrated by:
#include <stdio.h>
int main(int argc, char *argv[])
{
char *woot[2];
woot[0]="/";
woot[1]=0;
execvp(*woot,woot);
printf("Thingy!\n");
return 0;
}
Your solution makes ash bigger. Now I admit this ash getting bigger happens
if you just leave it sitting there for a while, but what does ash do when the
exec fails? Is there away to avoid the stat() by just noticing that the exec
failed?
Rob
--
Never bet against the cheap plastic solution.
More information about the busybox
mailing list