ruby / ruby/fiddle

Fiddle::Pointer#[]= copies beyond the source pointer size

Open
#214 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
195
Forks
53
Avg merge
23h 57m
Merged PRs (30d)
1

Description

require "fiddle"

include Fiddle

dst = Pointer.malloc(32, RUBY_FREE)
src = Pointer.malloc(4, RUBY_FREE)

dst[0, 32] = "\x00" * 32
src[0, 4] = "\xAA\xBB\xCC\xDD"

# src is only 4 bytes, but 16 bytes are copied.
dst[0, 16] = src

puts dst.to_str(32)
        .bytes
        .first(16)
        .map { |b| "%02x" % b }
        .join(" ")

# aa bb cc dd ad 78 00 00 d8 2a a1 98 ad 78 00 00
# (In my environment)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the Ruby reproduction in the issue and inspect the implementation of Fiddle::Pointer#[]= to trace how a source Pointer is copied. Add regression coverage for a source pointer smaller than the requested destination range, then verify that bytes beyond the source pointer are not copied.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.