Buffer Overflow

163 views
Skip to first unread message

Alan Gutierrez

unread,
Aug 18, 2012, 10:57:27 AM8/18/12
to nod...@googlegroups.com
When I write beyond the end of a `Buffer`, nothing bad happens. I'm expecting a
earth-shattering kaboom, or at least an exception. I'm happier with the do
nothing behavior, but I'm wondering if there was any debate about whether or not
an exception should be raised when an is out of range. If so, what was the
reasoning behind do nothing?

--
Alan Gutierrez - http://twitter.com/bigeasy - http://github.com/bigeasy

Nathan Rajlich

unread,
Aug 18, 2012, 1:31:32 PM8/18/12
to nod...@googlegroups.com
When you write past the "length" of a buffer, you're not actually
writing to the underlying C buffer, you're just adding new numerical
properties to the Buffer Javascript wrapper object.
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+un...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

Alan Gutierrez

unread,
Aug 18, 2012, 3:35:57 PM8/18/12
to nod...@googlegroups.com
On Sat, Aug 18, 2012 at 10:31:32AM -0700, Nathan Rajlich wrote:
>
> On Sat, Aug 18, 2012 at 7:57 AM, Alan Gutierrez <al...@prettyrobots.com> wrote:
> > When I write beyond the end of a `Buffer`, nothing bad happens. I'm expecting a
> > earth-shattering kaboom, or at least an exception. I'm happier with the do
> > nothing behavior, but I'm wondering if there was any debate about whether or not
> > an exception should be raised when an is out of range. If so, what was the
> > reasoning behind do nothing?

> When you write past the "length" of a buffer, you're not actually
> writing to the underlying C buffer, you're just adding new numerical
> properties to the Buffer Javascript wrapper object.

Cool. Will it always be that way? I can imagine someone arguing that writing
beyond the end of a buffer should raise an exception and demand that range
checking be added to the `Buffer` object.

--
Alan Gutierrez - http://github.com/bigeasy - http://twitter.com/bigeasy
Reply all
Reply to author
Forward
0 new messages