home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / perl / 5306 < prev    next >
Encoding:
Internet Message Format  |  1992-08-13  |  1.2 KB

  1. Path: sparky!uunet!usc!news!netlabs!lwall
  2. From: lwall@netlabs.com (Larry Wall)
  3. Newsgroups: comp.lang.perl
  4. Subject: Re: How do I determine if variable is tainted
  5. Keywords: perl taint
  6. Message-ID: <1992Aug13.233259.17431@netlabs.com>
  7. Date: 13 Aug 92 23:32:59 GMT
  8. References: <1992Aug13.091038.28195@id.dth.dk>
  9. Sender: news@netlabs.com
  10. Organization: NetLabs, Inc.
  11. Lines: 24
  12. Nntp-Posting-Host: scalpel.netlabs.com
  13.  
  14. In article <1992Aug13.091038.28195@id.dth.dk> ej@id.dth.dk (Erik Johansen) writes:
  15. : I have been puzzled for some time because of a script
  16. : that stops because of an unsecure dependency in an eval.
  17. : What I really want is if anyone has a routine for listing
  18. : all the variables that are tainted.
  19.  
  20. You can get a list of variables with a variant on dumpvar.pl.  Once you
  21. know which variables you want to test, the following will tell you
  22. whether a variable is tainted or not:
  23.  
  24.     sub tainted {
  25.     local($@);
  26.     eval { kill 0 * $_[0] };
  27.     $@ =~ /^Insecure/;
  28.     }
  29.  
  30. (Earlier version of Perl don't have eval {}, so you'd have to use an
  31. ordinary eval, and backwhack the $ in the expression.)
  32.  
  33. Note that the kill above is perfectly safe--it sends a 0 signal to a
  34. null list of processes.
  35.  
  36. Larry
  37.