Skip to content

Make filepaths with null byte fail#2583

Merged
enebo merged 1 commit intojruby:masterfrom
lumeet:filename_with_null_byte
Feb 11, 2015
Merged

Make filepaths with null byte fail#2583
enebo merged 1 commit intojruby:masterfrom
lumeet:filename_with_null_byte

Conversation

@lumeet
Copy link
Contributor

@lumeet lumeet commented Feb 9, 2015

This patch applies to several methods that deal with filepaths in Dir,
File, File::Stat, IO, and Kernel. All of these methods now raise an
argument error if a null byte is detected in a path argument.

Some of these methods are also slightly refactored, mostly by replacing
context.runtime with just runtime where applicable.

MRI uses StringValueCstr extensively for this purpose. In JRuby StringSupport.checkEmbeddedNulls seems to do the same job unless I've missed something.

After http://jira.codehaus.org/browse/JRUBY-4828, at least File.read raised a SecurityError with the same message but the current 1.7 branch doesn't seem to have any of these checks.

This patch applies to several methods that deal with filepaths in Dir,
File, File::Stat, IO, and Kernel. All of these methods now raise an
argument error if a null byte is detected in a path argument.

Some of these methods are also slightly refactored, mostly by replacing
context.runtime with just runtime where applicable.
@enebo enebo added this to the 9.0.0.0.pre2 milestone Feb 11, 2015
enebo added a commit that referenced this pull request Feb 11, 2015
@enebo enebo merged commit ab22fca into jruby:master Feb 11, 2015
@lumeet lumeet deleted the filename_with_null_byte branch February 11, 2015 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants