Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buffer header values converted to strings #1006

Open
tleasure opened this issue Mar 9, 2023 · 0 comments
Open

Buffer header values converted to strings #1006

tleasure opened this issue Mar 9, 2023 · 0 comments

Comments

@tleasure
Copy link

tleasure commented Mar 9, 2023

Environment Information

  • OS [e.g. Mac, Arch, Windows 10]: CentOS 7
  • Node Version [e.g. 8.2.1]: 16.15.0
  • NPM Version [e.g. 5.4.2]: 8.5.5
  • C++ Toolchain [e.g. Visual Studio, llvm, g++]: g++
  • node-rdkafka version [e.g. 2.3.3]: 2.15.0

Steps to Reproduce
Run attached test script. It will crash, trying to do a readInt32LE() operation on the Buffer due to it being previously converted to a string value.

node-rdkafka Configuration Settings
see script

Additional context
The issue is resolved when applying PR #968. Sample file to reproduce: test.js.txt

Output from 2.15.0 module

rebalance_cb called
running producer...
data.value: test-payload-value
[ { myID: <Buffer 43 02> } ]
node:internal/buffer:84
    throw new ERR_BUFFER_OUT_OF_BOUNDS();
    ^

RangeError [ERR_BUFFER_OUT_OF_BOUNDS]: Attempt to access memory outside buffer bounds
    at new NodeError (node:internal/errors:372:5)
    at boundsError (node:internal/buffer:84:11)
    at Uint8Array.readInt32LE (node:internal/buffer:390:5)
    at KafkaConsumer.<anonymous> (test.js:38:39)
    at KafkaConsumer.emit (node:events:527:28)
    at readCallback (./node_modules/node-rdkafka/lib/kafka-consumer.js:448:12) {
  code: 'ERR_BUFFER_OUT_OF_BOUNDS'
}

Output from patched module

rebalance_cb called
running producer...
data.value: test-payload-value
[ { myID: <Buffer 43 02 00 00> } ]
myIDVal should be 579: 579
myIDVal type should be 'number': number
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

No branches or pull requests

1 participant