LP#1298985: Protect against bad summary types
authorThomas Berezansky <tsbere@mvlc.org>
Fri, 28 Mar 2014 13:27:56 +0000 (09:27 -0400)
committerGalen Charlton <gmc@esilibrary.com>
Tue, 16 Jun 2015 15:12:50 +0000 (15:12 +0000)
Ensure that if we are asked for summary information in Patron Information that
we have any form of definition for it *and* we have code to call. If neither
case is true pretend they didn't ask for any to begin with.

Testing notes
-------------
Here is an example of the sort of request that, prior to this patch,
could cause a SIPServer backend to crash:

6300020150615    111700      Y   AOUinst|AAuser|

Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Sip/MsgType.pm

index 779d41d..afada58 100644 (file)
@@ -929,6 +929,12 @@ sub summary_info {
         return '';
     }
 
+    if ($summary_type > $#summary_map || not defined $summary_map[$summary_type]->{func}) {
+        # Huh, we don't have any code to handle the requested summary information.
+        # Pretend nothing was asked for instead.
+        return '';
+    }
+
     syslog("LOG_DEBUG", "Summary_info: index == '%d', field '%s'",
           $summary_type, $summary_map[$summary_type]->{fid});