Skip to content

Reject database filenames and VFS names containing NUL - #732

Merged
flavorjones merged 1 commit into
mainfrom
card-318-nul-filename
Aug 11, 2026
Merged

Reject database filenames and VFS names containing NUL#732
flavorjones merged 1 commit into
mainfrom
card-318-nul-filename

Conversation

@flavorjones

Copy link
Copy Markdown
Member

Database.new silently truncated a filename containing an embedded NUL at the NUL, then opened the truncated path with the default READWRITE | CREATE flags. A path that passed application-level checks in full could therefore open, or create, a different file than the application validated. The zvfs argument and UTF-16 filenames were truncated the same way. Ruby stdlib path APIs raise ArgumentError on embedded NUL; this extension did not.

Database.new now raises ArgumentError when the filename or VFS name contains an embedded NUL byte, or when a UTF-16 filename contains an embedded 0x0000 code unit, and does not open or create any file.

`Database.new` silently truncated a filename containing an embedded NUL
at the NUL, then opened the truncated path with the default
`READWRITE | CREATE` flags. A path that passed application-level checks
in full could therefore open, or create, a different file than the
application validated. The `zvfs` argument and UTF-16 filenames were
truncated the same way. Ruby stdlib path APIs raise `ArgumentError` on
embedded NUL; this extension did not.

`Database.new` will now raise `ArgumentError` when the filename or VFS
name contains an embedded NUL byte, or when a UTF-16 filename contains
an embedded 0x0000 code unit, and will not open or create any file.
@flavorjones
flavorjones enabled auto-merge (squash) August 11, 2026 19:59
@flavorjones
flavorjones merged commit abcb0f6 into main Aug 11, 2026
268 of 269 checks passed
@flavorjones
flavorjones deleted the card-318-nul-filename branch August 11, 2026 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant