Clamp mtime to +/- 2**31.

This commit is contained in:
Peter J. Holzer 2021-01-31 13:36:33 +01:00
parent 615742845e
commit 23998cefbd
1 changed files with 8 additions and 0 deletions

View File

@ -543,6 +543,14 @@ sub db_record_version {
my $t2b = gettimeofday();
$self->{times}{db_record_version_versions2_get_version_id} += $t2b - $t2a;
unless ($version_id) {
# We use a 32 bit int field in the database, so we have to clamp the mtime to that range.
# Need to fix this sometime before 2038 :-)
if ($f->{m} < -2147483648) {
$f->{m} = -2147483648;
} elsif ($f->{m} > 2147483647) {
$f->{m} = 2147483647;
}
$self->log(10, "insert into versions2(..., file_mtime=$f->{m}, ...)");
# XXX why is $f->{checksum} undef here for ./bin/dash?
$self->{dbh}->do("insert into versions2(
file_type, file_size, file_mtime,