Bug 18854 - Protect from DOS
commita64d14db20ac55fe4bcc8de06207c516d2237788
authorChris Cormack <chris@bigballofwax.co.nz>
Sun, 25 Jun 2017 05:34:12 +0000 (25 17:34 +1200)
committerFridolin Somers <fridolin.somers@biblibre.com>
Tue, 18 Jul 2017 13:28:44 +0000 (18 15:28 +0200)
tree4bf6c9a186cf287be6107e76ab42db83b2b7880a
parentcffb4a26b3264137130d7a1a3c287d1f17c05b77
Bug 18854 - Protect from DOS

There was a bug that meant a very large offset in the search params
will cause the search script to run forever (or long enough to crash
the machine)

To test

1/ Get ready with sudo top so you can kill the thread before it causes
your machine to OOM
2/ Hit a page like yourdomain.com/cgi-bin/koha/opac-search.pl?q=1&offset=-9999999999999999999
3/ Notice the process runs for a long time
4/ Kill the process
5/ Apply the patch
6/ Hit the page again, notice the it loads (offset is set to zero)
7/ Do the same to search in the staff client

Signed-off-by: Mirko Tietgen <mirko@abunchofthings.net>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Amended: changed -2 to 0 in opac-search.pl.
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
(cherry picked from commit 99b32717cd2596ce89a2d46b8cb4ddbba2dea5ad)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
catalogue/search.pl
opac/opac-search.pl