in reply to Please explain this tainting behaviour
The key is that it uses $_[0] as part of the argument to the kill function. That function is affected by taint checks; if $_[0] is tainted, Perl will refuse to let it or something calculated from get passed to kill. It will raise an exception instead.
Normally, an exception aborts your program. However, in this case, the statement in question is inside an eval BLOCK construct. If an exception occurs inside, only the code in that block is aborted, and the surrounding code can examine the exception by looking at the $@ variable. The above code does that to check whether it's a Perl error message starting with "Insecure", which would happen if $_[0] was tainted.
Multiplying $_[0] with zero is a trick. If $_[0] is not tainted, kill will be called. Despite the name, kill does not necessarily kill processes; it sends them signals. By multiplying with zero, you make sure that you always send signal zero, and that is a no-op that does nothing to the receiving process. Sending signal zero is normally used to check if a process with the given PID exists.
Makeshifts last the longest.
|
|---|