home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!usc!news!netlabs!lwall
- From: lwall@netlabs.com (Larry Wall)
- Newsgroups: comp.lang.perl
- Subject: Re: How do I determine if variable is tainted
- Keywords: perl taint
- Message-ID: <1992Aug13.233259.17431@netlabs.com>
- Date: 13 Aug 92 23:32:59 GMT
- References: <1992Aug13.091038.28195@id.dth.dk>
- Sender: news@netlabs.com
- Organization: NetLabs, Inc.
- Lines: 24
- Nntp-Posting-Host: scalpel.netlabs.com
-
- In article <1992Aug13.091038.28195@id.dth.dk> ej@id.dth.dk (Erik Johansen) writes:
- : I have been puzzled for some time because of a script
- : that stops because of an unsecure dependency in an eval.
- :
- : What I really want is if anyone has a routine for listing
- : all the variables that are tainted.
-
- You can get a list of variables with a variant on dumpvar.pl. Once you
- know which variables you want to test, the following will tell you
- whether a variable is tainted or not:
-
- sub tainted {
- local($@);
- eval { kill 0 * $_[0] };
- $@ =~ /^Insecure/;
- }
-
- (Earlier version of Perl don't have eval {}, so you'd have to use an
- ordinary eval, and backwhack the $ in the expression.)
-
- Note that the kill above is perfectly safe--it sends a 0 signal to a
- null list of processes.
-
- Larry
-