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
This adds support to use offset and length arguments above uint32
and it validates the input to make sure the arguments do not overflow.
Before, if the input would overflow, it would cause the write to be
performt in the wrong spot / result in unexpected behavior.
Instead, just use a strict number validation.
Fixes: nodejs#27043
All other Node.js Buffer methods either support negative offsets or throw errors for all negative integers stating that offset must be >= 0.
However,
buf.write(string, offset)
does not check if an offset is negative, but just converts it to uint32:node/lib/buffer.js
Line 896 in 6eae414
This may cause some slightly confusing effects:
-offset
is >-buffer.constants.MAX_LENGTH
, this produces not so clear error:-offset
is <-buffer.constants.MAX_LENGTH
,string
can be written in an unexpected place:So should the method check the sign before the converting?
The text was updated successfully, but these errors were encountered: