Brad Fitzpatrick (bradfitz) wrote in lj_dev,
Brad Fitzpatrick

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).

---	Sat May 19 12:13:02 2001
+++	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

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded