| Status | Draft |
|---|---|
| Author | James M Snell |
| Date | 25 Jan 2016 |
- Soft-Deprecate the existing
Buffer()constructors and introduce newBuffer.from(),Buffer.alloc()andBuffer.allocUnsafe()factory methods to address Buffer API usability and security concerns. - Add
--zero-fill-bufferscommand line option to node to force all Buffers to zero-fill when created
The details of the proposal are captured by Pull Request 4682 in the nodejs/node repository (https://github.com/jasnell/node/tree/buffer-safe).
Allocates a new initialized buffer of size bytes. If fill is specified
and is a string, the Buffer is allocated off the shared pool by calling:
Buffer.allocUnsafe(size).fill(fill);
Otherwise, the buffer is initialized by allocating new zero-filled memory
Allocates a new uninitialized buffer of size bytes off the shared pool. This
is equivalent to calling new Buffer(size)
Replaces the existing new Buffer(value[, encoding]) constructors.
Forces all Buffers to be zero-filled upon allocation.