a technical notebook
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
2.0 KiB

  1. <h1>Thursday, April 9</h1>
  2. CGI::Fast and multi_param()
  3. ---------------------------
  4. A little while ago, changes were made to [Perl's CGI.pm][1] because of a [class
  5. of exploits][2] arising from calling `param()` in list context.
  6. I had code in a wrapper for [Display][3] that called `param()` in list context
  7. deliberately:
  8. # Handle input from FastCGI:
  9. while (my $query = CGI::Fast->new) {
  10. my @params = $query->param('keywords');
  11. print $d->display(@params);
  12. }
  13. In due course, I started getting warnings about calling `param()` in list context.
  14. They looked sort of like this:
  15. brennen@exuberance 18:46:13 /home/brennen/www (master) ★ perl display.fcgi 2>&1 | head -1
  16. CGI::param called in list context from package main line 38, this can lead to vulnerabilities. See the warning in "Fetching the value or values of a single named parameter" at /usr/local/share/perl/5.20.1/CGI.pm line 408.
  17. Problematic, since a variable containing that list is _exactly what I want_. On
  18. googling, I found that in addition to the warning, CGI.pm had been amended to
  19. include `multi_param()` for [the cases][4] where you explicitly want a list.
  20. Ok, cool, I'll use that.
  21. Fast forward to just now. `display.fcgi` is blowing up on my local machine. Why?
  22. [Thu Apr 09 18:28:29.606663 2015] [fcgid:warn] [pid 13984:tid 140343326992128] [client 127.0.0.1:41335] mod_fcgid: stderr: Undefined subroutine CGI::Fast::multi_param
  23. Well, ok, I upgraded Ubuntu a while back. Maybe I need to reinstall CGI::Fast
  24. from CPAN because the Ubuntu packages aren't up to date. So:
  25. $ sudo cpan -i CGI::Fast
  26. No dice. What am I missing here? Oh, right. CGI::Fast inherits from CGI.pm.
  27. $ sudo cpan -i CGI
  28. Golden.
  29. Granted, I should probably stop using CGI.pm altogether.
  30. [1]: http://search.cpan.org/~leejo/CGI-4.14/lib/CGI.pod
  31. [2]: http://seclists.org/vulnwatch/2006/q4/6
  32. [3]: https://github.com/brennen/display
  33. [4]: http://search.cpan.org/~leejo/CGI-4.14/lib/CGI.pod#Fetching_the_value_or_values_of_a_single_named_parameter: