If someone externally links a truncated URL, for example:
http://www.example.com/node/380?from=100&comments_per_page
or if someone deliberately passes zero as a parameter:
http://www.example.com/node/380?from=100&comments_per_page=0
then it is possible for the pages to be passed zero as a parameter, which will result in a divide by zero, and spam in the logs.

Workaround:

In file: "includes/pager.inc"
in function: "pager_query"
I inserted as follows:

function pager_query($query, $limit = 10, $element = 0, $count_query = NULL) {
global $pager_page_array, $pager_total, $pager_total_items;
if (empty($limit)) { $limit=10; } // Avoid divide by zero - Dewi.
$page = isset($_GET['page']) ? $_GET['page'] : '';

CommentFileSizeAuthor
#1 23465.patch504 bytesneclimdul

Comments

neclimdul’s picture

Version: 5.7 » 5.x-dev
Status: Active » Needs review
StatusFileSize
new504 bytes

Quick patch based on this. Slightly different but smaller.

Apologies for the patch being from git but cvs wasn't responding.

tr’s picture

Version: 5.x-dev » 6.x-dev

Issue does not occur in 8.x or 7.x. DBTNG disables the pager entirely if limit is 0, FALSE, or NULL. (See PagerDefault->limit() and PagerDefault->execute() in includes/pager.inc)

However, issue is still present in 6.x, so I'm moving this to the 6.x queue for consideration.

Patch applies and works to address the issue raised by the original poster. My only question would be whether the limit should default to 10 if it's missing or zero (which is what the patch currently does), or whether the behavior should be to disable the pager like in 8.x and 7.x.

tr’s picture

#1: 23465.patch queued for re-testing.

Status: Needs review » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.