[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: SECURITY PROBLEM: autofs [all versions]



Steve Greenland wrote:
> 
> On 05-Jul-00, 17:29 (CDT), "Christopher W. Curtis" <ccurtis@aet-usa.com> wrote:
> > Joey Hess wrote:
> > >
> > > Christopher W. Curtis wrote:
> > > > However:
> > > >
> > > > int main()
> > > > {     FILE *foo = popen( "non-executable.file", "r+ );
> > > >       fprintf( foo, "hmm" );
> > > > }
> > >
> > > Hint: you must #include <stdio.h> to use popen
> >
> > Clue: both popen and fprintf will run fine without a declaration.
> 
> Clue: That's not what the standard says. Claims about the behavior of
> functions called without a declaration can be justifiably ignored.

Which C standard are you looking at?

If no declaration is supplied, one is created on the fly based on the
first occurance of the call.  If you give it the right parameters, it'll
run fine.  If you give it wrong parameters, it will probably misbehave,
but it will be called either way.

> > Clue: <stdio.h> needs to be included to typedef FILE
> 
> Doesn't this contradict your previous "clue"? How are you going to "use"
> popen and fprintf without a FILE *?

simple:  popen( "script_without_io" );

Could use just use system()?  I'm sure you could.  Under Windows this
opens a DOS box.  Does popen()?  I dunno.  Maybe not.  If a FILE*
_required_?  Absolutely not.

> > > Hint: popen returns NULL if it fails.
> >
> > Clue: popen failed because the program couldn't be executed.
> 
> Clue: The presumed point of your example (the behavior of the fprintf()
> call) is irrelevant, because you didn't check the value returned by
> popen.

Which is precisely my point with init scripts failing to run a program
because they don't check if it is executable.

> No, actually, your example is pointless because it doesn't even compile.

Surely someone as familiar with the C standard as you would be able to
fix it so that it does compile.

Christopher



Reply to: