in reply to Wrong return code after a system call

system returns the exit code of the executed system call. Since your system call is returning -1, a truth value, your code thinks everything went ok. Believe it or not, the only way your program would die is if the call executed properly and the called program exited with a 0 status (since default successful exit status is 0). Something like the following would probably be what you want:

system("/msg/spgear/tools/bin/perl $1"); die "Could not run program: $1 -- $!$/" if $? == -1;

That aside, you need to REALLY reconsider your regex pulling out your execute call. Someone could quite easily pass "EXECUTE:-e'0';rm -rf /" to your program. See the problem?

Hope this helps.

antirice    
The first rule of Perl club is - use Perl
The
ith rule of Perl club is - follow rule i - 1 for i > 1

Replies are listed 'Best First'.
Re: Re: Wrong return code after a system call
by PodMaster (Abbot) on Oct 24, 2003 at 07:25 UTC
    That aside, you need to REALLY reconsider your regex pulling out your execute call. Someone could quite easily pass "EXECUTE:-e'0';rm -rf /" to your program. See the problem?
    Yes, I agree, he should most definetly sidestep the issue entirely (perldoc -f system and perldoc -f exec cover the details).

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.