From 23998cefbdbc60bf8d3c9251d406f4e8dbfd31f5 Mon Sep 17 00:00:00 2001 From: "Peter J. Holzer" Date: Sun, 31 Jan 2021 13:36:33 +0100 Subject: [PATCH] Clamp mtime to +/- 2**31. --- lib/Simba/CA.pm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/Simba/CA.pm b/lib/Simba/CA.pm index 5907630..6a144a2 100644 --- a/lib/Simba/CA.pm +++ b/lib/Simba/CA.pm @@ -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,