Skip to content

writeFileAll lacks sufficient unit test coverage #7014

@LemonBoy

Description

@LemonBoy

writeFileAll (and writeFileAllUnseekable together with writeFileAllSendfile) are underspecified and can easily turn into infinite loops:

  • *Unseekable enters an infinite loop whenever in_offset is past the input EOF,
  • Same for *Sendfile, you get stuck in a loop where sendfile keeps reading zero bytes,
  • (In *Sendfile) If count is zero you can't really tell if the offset is valid or not as you don't know where the EOF is,
  • /// If the size of the source file is known, passing the size here will save one syscall. the extra stat call is never done in any case, not knowing the file size leads to the previous problem,
  • There's no mention that the iovecs can be mutated in case of short writes (mutating the input parameters makes the API even more awful than it already is, the caller cannot reuse the iovec array across calls),
  • The test coverage is absymal, there's no explicit test with pipes and/or other unseekable files

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorcontributor friendlyThis issue is limited in scope and/or knowledge of Zig internals.standard libraryThis issue involves writing Zig code for the standard library.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions