tls: fix pool usage race
authorFedor Indutny <fedor.indutny@gmail.com>
Fri, 29 Nov 2013 16:09:59 +0000 (20:09 +0400)
committerTimothy J Fontaine <tjfontaine@gmail.com>
Mon, 2 Dec 2013 23:18:04 +0000 (15:18 -0800)
commit60f777d343c5aea9021f008c4fb07541ccba4ad4
tree7ad316a50df9c12ef682337f9d5ea207c4760aed
parentbd7fa92de421048b0eb8fb810eb66829424fc07f
tls: fix pool usage race

When calling `encOut` in loop, `maybeInitFinished()` may invoke
`clearOut`'s loop, leading to the writing of interleaved data
(encrypted and cleartext) into the one shared pool.

Move `maybeInitFinished()` out of the loop and add assertion for
future.
lib/tls.js
test/simple/test-tls-interleave.js [new file with mode: 0644]