Skip to content

integer truncation in truncate on Windows #24466

Closed
@simonster

Description

While ios_trunc accepts a size argument of type size_t, it calls _chsize, which takes a long (32-bit int on Windows), and it doesn't check for overflow. As a result, this fails:

open("some_file_name", "w") do f
    truncate(f, 2^31+1)
end

ios_trunc should probably be modified to use _chsize_s.

(Originally reported as JuliaIO/JLD2.jl#50.)

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behaviorioInvolving the I/O subsystem: libuv, read, write, etc.system:windowsAffects only Windows

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions