Brad Fitzpatrick (bradfitz) wrote in lj_dev,
Brad Fitzpatrick
bradfitz
lj_dev

I suck.

Sorry for wasting many people's time that would have otherwise been spent sleeping.

This fixes the infinite loop that was eating up CPU and memory and crashing machines when they ran out of swap.

I wasn't trusting user input here ... I already validated their opts at another place, but in this case $q->{'opts'} was NULL, which is mapped to "undef" by DBI, so from, to, and by were all zero in numeric context. I got paranoid though and added the $by > 0 and int($by) checks... all that should be necessary is unless ($by).

--- ljpoll.pl.orig	Sat May 19 12:13:02 2001
+++ ljpoll.pl	Sat May 19 12:02:10 2001
@@ -549,6 +549,7 @@
 	    ## manually add all the possible values, since they aren't in the database
 	    ## (which was the whole point of making a "scale" type):
 	    my ($from, $to, $by) = split(m!/!, $q->{'opts'});
+	    $by = 1 unless ($by > 0 and int($by) == $by);
 	    for (my $at=$from; $at<=$to; $at+=$by) {
 		push @{$its{$qid}}, [ $at, $at ];  # note: fake itemid, doesn't matter, but needed to be unique
 	    }
Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 15 comments