[patch] prevent ash executing non-files

walter harms wharms at bfs.de
Sun Sep 10 18:47:01 UTC 2006


hi all,
the problem is that while testing ash did not return !0
the size increase is ok when it prevents that this happens.

re,
 wh

Rob Landley wrote:
> 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



More information about the busybox mailing list