[open-ils-commits] [GIT] Evergreen ILS branch rel_2_9 updated. 2f6c95e5583f39fb87b5809a553b0bbb26e3cd4c

Evergreen Git git at git.evergreen-ils.org
Fri Oct 23 23:57:34 EDT 2015


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, rel_2_9 has been updated
       via  2f6c95e5583f39fb87b5809a553b0bbb26e3cd4c (commit)
       via  e515641934fda61ecf0820c5dee607085d90c6cf (commit)
      from  098db2e559fb4d61215b527b7cceb50b68b1fa8e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 2f6c95e5583f39fb87b5809a553b0bbb26e3cd4c
Author: Galen Charlton <gmc at esilibrary.com>
Date:   Fri Oct 23 20:03:07 2015 +0000

    LP#1509479: set a limit on loops in QP's decompose() method
    
    Following a suggestion of Dan Scott's, add a pair of
    suspenders to the belt and enforce an arbitrary limit
    of 1000 passes through QP->decompse().
    
    Signed-off-by: Galen Charlton <gmc at esilibrary.com>
    Signed-off-by: Dan Scott <dscott at laurentian.ca>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/QueryParser.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/QueryParser.pm
index ba90f18..7f1f235 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/QueryParser.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/QueryParser.pm
@@ -951,8 +951,14 @@ sub decompose {
 
     my $remainder = '';
 
+    my $loops = 0;
     while (!$remainder) {
-        warn '  'x$recursing."Start of the loop. last_type: $last_type, joiner: ".$struct->joiner.", struct: $struct\n" if $self->debug;
+        $loops++;
+        warn '  'x$recursing."Start of the loop. loop: $loops last_type: $last_type, joiner: ".$struct->joiner.", struct: $struct\n" if $self->debug;
+        if ($loops > 1000) { # the most magical of numbers...
+            warn '  'x$recursing." got to $loops loops; aborting\n" if $self->debug;
+            last;
+        }
         if ($last_type eq 'FEND' and $fstart and $fstart !=  $struct) { # fall back further
             $remainder = $_;
             last;

commit e515641934fda61ecf0820c5dee607085d90c6cf
Author: Galen Charlton <gmc at esilibrary.com>
Date:   Fri Oct 23 19:23:05 2015 +0000

    LP#1509479: fix infinite loop bug in QueryParser
    
    An unclosed phrase search that has a modifier can cause QueryParser to
    enter an infinite loop, tying up open-ils.storage backends.
    
    Examples of such searches include:
    
      -"cats and dogs
      subject:+"physical chemistry
    
    This patch fixes the bug by allowing the end of the query string
    to terminate a phrase (in addition to a quotation mark).
    
    To test:
    
    [1] Verify that the t/21-QueryParser.t unit test passes
    [2] To test in a *development* database, before applying the patch
        run one of the example queries.  Observe that no
        results are returned, and that one of the open-ils.storage
        drones is running at 100% CPU.
    [3] Apply the patch and restart the open-ils.storage service.
    [4] Try the query again; this time, it should return results
        immediately without causing an open-ils.storage drone to
        peg a CPU.
    
    Signed-off-by: Galen Charlton <gmc at esilibrary.com>
    Signed-off-by: Dan Scott <dscott at laurentian.ca>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/QueryParser.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/QueryParser.pm
index 1b5458d..ba90f18 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/QueryParser.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/QueryParser.pm
@@ -1159,7 +1159,7 @@ sub decompose {
             $_ = $';
 
             $last_type = 'CLASS';
-        } elsif (/^\s*($$r{required_re}|$$r{disallowed_re}|$$r{negated_re})?"([^"]+)"/) { # phrase, always anded
+        } elsif (/^\s*($$r{required_re}|$$r{disallowed_re}|$$r{negated_re})?"([^"]+)(?:"|$)/) { # phrase, always anded
             warn '  'x$recursing.'Encountered' . ($1 ? " ['$1' modified]" : '') . " phrase: $2\n" if $self->debug;
 
             my $req_ness = $1 || '';
diff --git a/Open-ILS/src/perlmods/t/21-QueryParser.t b/Open-ILS/src/perlmods/t/21-QueryParser.t
index 55ffd6f..81bf051 100644
--- a/Open-ILS/src/perlmods/t/21-QueryParser.t
+++ b/Open-ILS/src/perlmods/t/21-QueryParser.t
@@ -60,6 +60,18 @@ is($QParser->superpage(), 1, 'Superpage stays set');
 is($QParser->superpage_size(1000), 1000, 'Superpage size setting works');
 is($QParser->superpage_size(), 1000, 'Superpage size stays set');
 
+init_qp();
+eval {
+    local $SIG{ALRM} = sub { die "timed out!\n" };
+    alarm 1;
+    $QParser->parse('-"unclosed phrase');
+};
+if ($@) {
+    fail('parsing modified unclosed phrase query timed out');
+} else {
+    pass('successfully parsed modified unclosed phrase query');
+}
+
 # It's unfortunate not to be able to use the following tests immediately, but
 # they reflect assumptions that need to be updated in light of new qp_fix code.
 # Also,, canonicalization may not preserve insignificant whitespace nor the

-----------------------------------------------------------------------

Summary of changes:
 .../lib/OpenILS/Application/Storage/QueryParser.pm |   10 ++++++++--
 Open-ILS/src/perlmods/t/21-QueryParser.t           |   12 ++++++++++++
 2 files changed, 20 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list