From f0af3b09bd55f5564d22a14b43de7603f98304c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=BA=D0=BE=D0=B2=D0=BE=D1=80=D0=BE=D0=B4=D0=B0=20?= =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=B8=D1=82=D0=B0=20=D0=90=D0=BD=D0=B4=D1=80?= =?UTF-8?q?=D0=B5=D0=B5=D0=B2=D0=B8=D1=87?= Date: Tue, 5 Jun 2018 22:53:03 +0300 Subject: [PATCH] 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 Reviewed-By: Evan Lucas Reviewed-By: Tiancheng "Timothy" Gu Reviewed-By: Michael Dawson --- doc/api/buffer.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/api/buffer.md b/doc/api/buffer.md index 2b63b4eb2e13f2..1ed15e28d50c7c 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -1177,8 +1177,12 @@ console.log(Buffer.allocUnsafe(3).fill('\u0222')); // Prints: ``` -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);