doc: buffer.fill() can zero-fill on invalid input

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 <info@bnoordhuis.nl>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
This commit is contained in:
Сковорода Никита Андреевич 2018-06-05 22:53:03 +03:00 committed by Evan Lucas
parent 555696df51
commit f0af3b09bd

View File

@ -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);