Commit Graph
19 Commits
Author SHA1 Message Date
Maxwell Krohn a22a2d8656 tls: stop NodeBIO::Gets from reading off end of buffer
NodeBIO::Gets was reading off the end of a buffer if it
didn't find a "\n" before the EOF.  This behavior
was causing X509 certificates passed to `https.Agent`
via the "ca" option to be silently discarded. It also
was causing improper parsing of certs and keys
passed to https.Agent, but those problems were worked
around in cdde9a3.

Backed out workaround in `lib/crypto.js` from ccde9a3,
which now isn't needed.  But keep the test introduced
in that commit, which tests properly for this
bug.

This bug was first introduced in a58f93f

Gist containing test code, bisection log, and notes:
   https://gist.github.com/maxtaco/9211605
2014-02-26 17:33:10 +04:00
Fedor Indutny 06b1945298 crypto: fix moving read head
Fix various possible stalls of read head (i.e. try moving it after every
write head update).

NOTE: This is actually backported from `bud`.
2013-12-07 03:48:43 +04:00
Fedor Indutny 03747f69fb tls_wrap: use writev when possible
Try writing multiple chunks from NodeBIO if possible.
2013-12-07 03:47:57 +04:00
Fedor Indutny 014ab77276 crypto: try moving read head in Peek()
Otherwise it might get stall (`Peek()` will return zero-length chunk)
in following situation:

1. `Write(kBufferLength)`
2. `Read(kBufferLength)`
3. `Write(anything)`
4. `Peek()` => `len=0`
2013-11-08 17:01:02 +04:00
Fedor Indutny 2bc30f239b cpplint: disallow if one-liners 2013-10-17 00:34:19 +04:00
Ben Noordhuis 653f62a709 crypto: remove NodeBIO::GetMethod()
Remove NodeBIO::GetMethod() and replace calls to BIO_new() with calls
to the new NodeBIO::New() function.

This commit basically reshuffles some code in order to make it explicit
that the NodeBIO BIO_METHOD is const.
2013-08-29 14:25:57 +02:00
Fedor Indutny e5791f74f0 crypto: fix another over-run in bio
When doing `FreeEmpty`, `NodeBIO` skips pre-allocated `head_` buffer.
However this might lead to double-freeing buffers since in `~NodeBIO()`
we're starting deallocation from `head_` buffer.
2013-08-03 14:04:55 +04:00
Fedor Indutny 8e29ce9f13 src: lint c++ code 2013-07-31 22:12:06 +04:00
Fedor Indutny 4ae96c885b crypto: do not move half-filled write head
Might cause write head running over read head, when there were no
allocation and `Commit()` was called. Source of at least one test
failure on windows (`simple/test-https-drain.js`).
2013-06-26 12:36:56 +02:00
Fedor Indutny bf8dc0762a crypto: change assertion to condition in bio
Read head can be the same as write head, even if there's some data to
read.
2013-06-19 22:03:07 +02:00
Fedor Indutny 03e008ddb8 tls_wrap: embed TLS encryption into streamwrap 2013-06-16 09:30:14 +02:00
Fedor Indutny 5dd155a3bb crypto: ensure that read head is always non-empty 2013-06-15 21:43:24 +02:00
Fedor Indutny 4536b27ac1 crypto: do not deallocate embedded buffer 2013-06-14 17:10:04 +02:00
Fedor Indutny 56d9c48573 crypto: fix excessive buffer allocation
Allocate buffer only if the next one isn't free.
2013-06-14 17:10:04 +02:00
Fedor Indutny 9ae1d182ba crypto: free excessive memory in NodeBIO
Before this commit NodeBIO never shrank, possibly consuming a lot of
memory (depending on reader's haste).

All buffers between write_head's child and read_head should be
deallocated on read, leaving only space left in write_head and in the
next buffer.
2013-06-08 15:40:57 +04:00
Fedor Indutny c9850952c9 crypto: move write_head in bio's Reset() method 2013-04-10 16:55:11 +04:00
Fedor Indutny 798d1772c0 crypto: fix changing buffers in bio
We should go to next buffer if *current* one is full, not the next one.
Otherwise we may hop through buffers and written data will become
interleaved, which will lead to failure.
2013-04-10 16:55:10 +04:00
Fedor Indutny 62a214268a crypto: fix style issues in bio
Stop changing arguments, use local variables for things that change.
2013-04-10 16:55:10 +04:00
Fedor Indutny 58f93ffc4a crypto: use better memory BIO implementation 2013-04-05 04:12:13 +04:00