buffer: fix range checks for slice() · nodejs/node@a9d528b · GitHub
Skip to content

Commit a9d528b

Browse files
trevnorrisMylesBorins
authored andcommitted
buffer: fix range checks for slice()
Using the black magic of Symbol.toPrimitive the numeric value of start/end can be changed when Uint32Value() is called once Buffer::Fill() is entered. Allowing the CHECK() to be bypassed. The bug report was only for "start", but the same can be done with "end". Perform checks for both in node::Buffer::Fill() to make sure the issue can't be triggered, even if process.binding is used directly. Include tests for each case. Along with a check to make sure the last time the value is accessed returns -1. This should be enough to make sure Buffer::Fill() is receiving the correct value. Along with two tests against process.binding directly. Fixes: #9149 PR-URL: #9174 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Franziska Hinkelmann <ranziska.hinkelmann@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
1 parent fa7d378 commit a9d528b

2 files changed

Lines changed: 78 additions & 1 deletion

File tree

src/node_buffer.cc

Lines changed: 2 additions & 1 deletion

test/parallel/test-buffer-fill.js

Lines changed: 76 additions & 0 deletions

0 commit comments

Comments
 (0)