sidorares / node-mysql2

:zap: fast mysqljs/mysql compatible mysql driver for node.js
https://sidorares.github.io/node-mysql2/
MIT License
3.94k stars 592 forks source link

fix: binary parser sometimes reads out of packet bounds when results … #2601

Closed Parsonswy closed 3 weeks ago

Parsonswy commented 3 weeks ago

Fixes #2602.

Check the nullBitmaskByte before trying to readLengthCodedBuffer() when typeCast: false on binary results.

sidorares commented 3 weeks ago

thanks for fix PR and detailed report @Parsonswy ! Do you think it would be possible to include a unit test ( failing without lib/parsers/binary_parser.js changes and passing with )?

The main change looks good to me

codecov[bot] commented 3 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 90.32%. Comparing base (2129818) to head (40f9224).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #2601 +/- ## ======================================= Coverage 90.32% 90.32% ======================================= Files 71 71 Lines 15725 15727 +2 Branches 1339 1339 ======================================= + Hits 14204 14206 +2 Misses 1521 1521 ``` | [Flag](https://app.codecov.io/gh/sidorares/node-mysql2/pull/2601/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andrey+Sidorov) | Coverage Δ | | |---|---|---| | [compression-0](https://app.codecov.io/gh/sidorares/node-mysql2/pull/2601/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andrey+Sidorov) | `90.32% <100.00%> (+<0.01%)` | :arrow_up: | | [compression-1](https://app.codecov.io/gh/sidorares/node-mysql2/pull/2601/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andrey+Sidorov) | `90.32% <100.00%> (+<0.01%)` | :arrow_up: | | [tls-0](https://app.codecov.io/gh/sidorares/node-mysql2/pull/2601/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andrey+Sidorov) | `89.85% <100.00%> (+<0.01%)` | :arrow_up: | | [tls-1](https://app.codecov.io/gh/sidorares/node-mysql2/pull/2601/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andrey+Sidorov) | `90.15% <100.00%> (+<0.01%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andrey+Sidorov#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

Parsonswy commented 3 weeks ago

@sidorares Certainly. Test added.

wellwelwel commented 3 weeks ago

LGTM 🚀