Skip to content

Commit

Permalink
doc: buffer.fill() can zero-fill on invalid input
Browse files Browse the repository at this point in the history
Note that buffer.fill() can zero-fill on some input types if no
valid fill data remains, but does nothing on other input types.

PR-URL: https://github.com/nodejs-private/node-private/pull/120
Fixes: https://github.com/nodejs-private/security/issues/193
Refs: https://github.com/nodejs-private/node-private/pull/118
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Evan Lucas <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
  • Loading branch information
ChALkeR authored and evanlucas committed Jun 12, 2018
1 parent 555696d commit f0af3b0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions doc/api/buffer.md
Original file line number Diff line number Diff line change
Expand Up @@ -1177,8 +1177,12 @@ console.log(Buffer.allocUnsafe(3).fill('\u0222'));
// Prints: <Buffer c8 a2 c8>
```

If `value` contains invalid characters, it is truncated; if no valid
fill data remains, no filling is performed:
If `value` contains invalid characters, it is truncated.

If no valid fill data remains, then the buffer is either zero-filled or no
filling is performed, depending on the input type. That behavior is dictated by
compatibility reasons and was changed to throwing an exception in Node.js v10,
so it's not recommended to rely on that.

```js
const buf = Buffer.allocUnsafe(5);
Expand Down

0 comments on commit f0af3b0

Please sign in to comment.