Protect against empty/invalid log_protect sections
authorDan Wells <dbw2@calvin.edu>
Wed, 31 Oct 2012 14:21:14 +0000 (10:21 -0400)
committerBill Erickson <berick@esilibrary.com>
Thu, 8 Nov 2012 17:48:40 +0000 (12:48 -0500)
Connectivity would fail if the log_protect section of opensrf_core.xml
was empty, or contained only comments, as it does in the default
example. Add a simple guard against this potential problem.  This fix
will also protect against cases where the 'log_protect' section
contains text rather than separate configuration elements.

Credit to Dan Scott for finding the bug and working out how to fix it.

Signed-off-by: Dan Wells <dbw2@calvin.edu>
Signed-off-by: Dan Scott <dan@coffeecode.net>
src/perl/lib/OpenSRF/Application.pm

index 93cb92d..9283b7f 100644 (file)
@@ -135,10 +135,12 @@ sub handler {
                my $logdata = "CALL: ".$session->service." $method_name ";
                my $redact_params = 0;
                if (@p) {
-                       foreach my $match_string (@{$shared_conf->shared->log_protect}) {
-                               if ($method_name =~ /^$match_string/) {
-                                       $redact_params = 1;
-                                       last;
+                       if (ref($shared_conf->shared->log_protect) eq 'ARRAY') {
+                               foreach my $match_string (@{$shared_conf->shared->log_protect}) {
+                                       if ($method_name =~ /^$match_string/) {
+                                               $redact_params = 1;
+                                               last;
+                                       }
                                }
                        }
                        if ($redact_params) {