diff options
author | Jeremy Evans <code@jeremyevans.net> | 2023-02-10 10:33:53 -0800 |
---|---|---|
committer | Jeremy Evans <code@jeremyevans.net> | 2023-03-24 12:29:00 -0700 |
commit | 6c60006de5cfd75f10a1b4a3d822e2de41d22db6 (patch) | |
tree | 846c8feffac56b046d35059a001d095c2283bda9 /io.c | |
parent | 836e9a192ba4fdc56a2d3d94f5840869f77fd3bf (diff) |
Raise ArgumentError if IO.read is provided negative offset
Fixes [Bug #19380]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/7289
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -12125,9 +12125,13 @@ static VALUE rb_io_s_read(int argc, VALUE *argv, VALUE io) { VALUE opt, offset; + long off; struct foreach_arg arg; argc = rb_scan_args(argc, argv, "13:", NULL, NULL, &offset, NULL, &opt); + if (!NIL_P(offset) && (off = NUM2LONG(offset)) < 0) { + rb_raise(rb_eArgError, "negative offset %ld given", off); + } open_key_args(io, argc, argv, opt, &arg); if (NIL_P(arg.io)) return Qnil; if (!NIL_P(offset)) { |