sidorares / sidorares/node-mysql2
error while parsing: "should not reach here"
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 4.4k
- Forks
- 680
- Avg merge
- 9h 7m
- Merged PRs (30d)
- 59
Description
~Snip stack:
at Packet.readLengthCodedNumberExt (/node_modules/mysql2/lib/packets/packet.js:207:11)
at Packet.readLengthCodedNumber (/node_modules/mysql2/lib/packets/packet.js:157:15)
at Packet.parseLengthCodedInt (/node_modules/mysql2/lib/packets/packet.js:668:29)
I can't tell exactly what the problem is, but it seems like there's no bounds check on the Packet.readLengthCodedNumber function.
if offset is greater than buffer's length, then byte2 is set to undefined, which breaks the rest of the code.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in lib/packets/packet.js around lines 152-158, then follow Packet.readLengthCodedNumber, readLengthCodedNumberExt, and parseLengthCodedInt from the reported stack trace. Use the case where offset exceeds the buffer length as the starting scenario; done means parsing no longer produces an undefined byte or reaches the reported error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mysql, node.js
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100