You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed this when debugging a separate issue relating to out of bounds reads in the binary parser.
Presently the binary parser does not check the NULL mask when the MySQL connection is configured with typeCast: false and will always attempt to readLengthCodedBuffer which causes the results to be nonsensical or the whole connection to panic. In my testing if there were less than three NULL values in the result row it just caused mangling, but after the fourth the connection state was corrupted.
I've created a PR that checks nullBitmaskByte before attempting to readLengthCodedBuffer() to go along with this issue. When the cell is null the parser will push NULL to the results. I considered doing an empty buffer, but thought that might be ambiguous since length 0 strings and empty blob fields would also be empty buffers, I think. I don't use typeCast: false in a meaningful capacity though so I am not attached to either approach.
constconnection=awaitmysql.createConnection({debug: true,typeCast: false...});connection.execute('SELECT n1,n2,n3,n4 FROM binparse',[],(error,result,fields)=>{console.log(result);});
Error: Should not reach here: undefined
at Packet.readLengthCodedNumberExt (/home/wyatt/Repos/2873-13-vw-cup-lxp-api/node_modules/mysql2/lib/packets/packet.js:232:11)
at Packet.readLengthCodedNumber (/home/wyatt/Repos/2873-13-vw-cup-lxp-api/node_modules/mysql2/lib/packets/packet.js:193:17) at Packet.readLengthCodedBuffer (/home/wyatt/Repos/2873-13-vw-cup-lxp-api/node_modules/mysql2/lib/packets/packet.js:398:22)
...
0 20130 ==> (no command)#(no command)(9,maybeOK,6)
node:events:491 throw er; // Unhandled 'error' event
^
...
Error: Unexpected packet while no commands in the queue
at Connection.protocolError (/home/wyatt/Repos/2873-13-vw-cup-lxp-api/node_modules/mysql2/lib/connection.js:409:17)
at Connection.handlePacket (/home/wyatt/Repos/2873-13-vw-cup-lxp-api/node_modules/mysql2/lib/connection.js:454:14)
...
fatal: true,
code: 'PROTOCOL_UNEXPECTED_PACKET'
The text was updated successfully, but these errors were encountered:
I noticed this when debugging a separate issue relating to out of bounds reads in the binary parser.
Presently the binary parser does not check the NULL mask when the MySQL connection is configured with
typeCast: false
and will always attempt toreadLengthCodedBuffer
which causes the results to be nonsensical or the whole connection to panic. In my testing if there were less than three NULL values in the result row it just caused mangling, but after the fourth the connection state was corrupted.I've created a PR that checks
nullBitmaskByte
before attempting toreadLengthCodedBuffer()
to go along with this issue. When the cell is null the parser will pushNULL
to the results. I considered doing an empty buffer, but thought that might be ambiguous since length 0 strings and empty blob fields would also be empty buffers, I think. I don't usetypeCast: false
in a meaningful capacity though so I am not attached to either approach.Test Table
Three Nulls
Four Nulls
The text was updated successfully, but these errors were encountered: