Skip to content

Crash in Date.encode if the date is long distant future #632

@t-ae

Description

@t-ae

Describe the issue

Date.encode method crashes if the date is long distant future

Vapor version

4.111.1

Operating system and version

macOS 26.3.1

Swift version

6.2.3

Steps to reproduce

No response

Outcome

No response

Additional notes

let seconds = self.timeIntervalSince(Self._psqlDateStart) * Double(Self._microsecondsPerSecond)
byteBuffer.writeInteger(Int64(seconds))

Date.encode internally computes its seconds from _psqlDateStart and convert it to Int64.
If the seconds is greater than Int64.max, this method crashes.

Fatal error: Double value cannot be converted to Int64 because the result would be greater than Int64.max

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions