dgram: fix send with out of bounds offset + length#40568
dgram: fix send with out of bounds offset + length#40568Linkgoron wants to merge 3 commits intonodejs:masterfrom
Conversation
4e3776a to
6b2f4fc
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Do we need to do the same checks for non-strings as well? The same test file verifies errors are thrown for some ranges, but I'm not sure if it covers all cases. |
I think you're correct and that the following (for example) might show a similar error: sock.send(Buffer.from('hello'), 3, 4);Maybe I should add the check for all inputs. |
6b2f4fc to
3fdfdac
Compare
It looks like in addition to strings, checks for |
fix Socket.prototype.send sending garbage when the message is a string, or Buffer and offset+length is out of bounds. Fixes: nodejs#40491
3fdfdac to
63a0887
Compare
3b23094 to
b392a94
Compare
dcde72f to
c829552
Compare
|
Landed in 3b9044b...2413283 |
fix Socket.prototype.send sending garbage when the message is a string, or Buffer and offset+length is out of bounds. Fixes: #40491 PR-URL: #40568 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
fix Socket.prototype.send sending garbage when the message is a string, or Buffer and offset+length is out of bounds. Fixes: #40491 PR-URL: #40568 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
fix Socket.prototype.send sending garbage when the message is a string, or Buffer and offset+length is out of bounds. Fixes: #40491 PR-URL: #40568 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
fix
Socket.prototype.sendsending garbage when the message is astring, andoffset+lengthis out of bounds.When a string message was sent with offset/length, the underlying buffer from
Buffer.fromwas sent without checking the original string's length, and garbage was sent if length/offset were too long. Instead, the method now throws anERR_OUT_OF_RANGEERR_BUFFER_OUT_OF_BOUNDSerror.Edit:
Also added checks for Buffers
Fixes: #40491