From 1317848782be1ad348de73c7016e413974f72c90 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 5 Sep 2014 18:40:05 +0800 Subject: [PATCH] Fix infinite loop with dognzb --- sickbeard/providers/newznab.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/sickbeard/providers/newznab.py b/sickbeard/providers/newznab.py index d4686b52..2042bab9 100755 --- a/sickbeard/providers/newznab.py +++ b/sickbeard/providers/newznab.py @@ -239,6 +239,18 @@ class NewznabProvider(generic.NZBProvider): except (AttributeError, TypeError): break + # sanity check - limiting at 10 at getting 1000 results in-case incorrect total parameter is reported + if params['limit'] > 1000: + logger.log("Excessive results for search, ending search", logger.WARNING) + break + + # sanity check - total should remain constant + if offset != 0 and total != initial_total: + logger.log("Total number of items on newznab response changed, ending search", logger.DEBUG) + break + else: + initial_total = total + # if there are more items available then the amount given in one call, grab some more if (total - params['limit']) > offset == params['offset']: params['offset'] += params['limit'] @@ -248,9 +260,7 @@ class NewznabProvider(generic.NZBProvider): else: break - # sanity check - limiting at 10 at getting 1000 results in-case incorrect total parameter is reported - if params['limit'] > 1000: - break + else: break