tls: remove harmful unnecessary bounds checking
authorMarcel Laverdet <marcel@laverdet.com>
Thu, 21 Mar 2013 21:56:02 +0000 (16:56 -0500)
committerFedor Indutny <fedor.indutny@gmail.com>
Sat, 23 Mar 2013 17:04:34 +0000 (00:04 +0700)
commit1526909083537e1092316ccf306f3b32a4b0bf4a
tree76acbc8f239861cbe1f21e2370858ce5d9c0e26f
parent14417fdb3fe68d0c0142e16359b75e9be44b1780
tls: remove harmful unnecessary bounds checking

The EncIn, EncOut, ClearIn & ClearOut functions are victims of some code
copy + pasting. A common line copied to all of them is:

`if (off >= buffer_length) { ...`

448e0f43 corrected ClearIn's check from `>=` to `>`, but left the others
unchanged (with an incorrect bounds check). However, if you look down at
the next very next bounds check you'll see:

`if (off + len > buffer_length) { ...`

So the check is actually obviated by the next line, and should be
removed.

This fixes an issue where writing a zero-length buffer to an encrypted
pair's *encrypted* stream you would get a crash.
src/node_crypto.cc