Skip to content

Commit

Permalink
Check for negative fileno.
Browse files Browse the repository at this point in the history
We return a negative fileno when a channel is not of a form from
which we can extract a real fileno. Not handling that case here
led to modes on the resulting IO to be incorrect, causing a stdin-
driven DATA to be marked as binmode incorrectly. This fixes that
issue and one MRI test (test_DATA_binmode in ruby/test_io.rb).
headius committed Jul 5, 2017
1 parent c02838c commit ddec5e2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/util/io/FilenoUtil.java
Original file line number Diff line number Diff line change
@@ -94,7 +94,7 @@ public int getNewFileno() {
}

public static boolean isFake(int fileno) {
return fileno >= FIRST_FAKE_FD;
return fileno < 0 || fileno >= FIRST_FAKE_FD;
}

public static int filenoFrom(Channel channel) {

0 comments on commit ddec5e2

Please sign in to comment.