Skip to content

Commit 0726f19

Browse files
committed
Add basic checking of flood control file
It fails when the filesystem gets full.
1 parent 5c0aeee commit 0726f19

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

log/humor.pl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
open FLOOD_CONTROL_FILE, '+<', 'humor/flood_control' or die "No flood control file writable.\n";
99

1010
#flood control time
11-
if ( time < (readline(FLOOD_CONTROL_FILE) + $FLOOD_SECS) ) { # I hope that file contains what I think it does
11+
my $last_time = readline(FLOOD_CONTROL_FILE);
12+
if ($last_time < 1) {
13+
die "Invalid file: humor/flood_control";
14+
}
15+
if ( time < $last_time + $FLOOD_SECS ) {
1216
exit 0;
1317
}
1418

0 commit comments

Comments
 (0)