From 98be8df571f92ad0b846209c21cc00139bc14805 Mon Sep 17 00:00:00 2001 From: Kai Groner Date: Thu, 18 Apr 2013 19:01:14 -0400 Subject: crypto: Make Decipher._flush() emit errors. When Decipher processes a stream using an incorrect key, the DecipherFinal() method throws an unhandled exception at the end of the stream. --- lib/crypto.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/crypto.js b/lib/crypto.js index 0cc70ff15..22141ff8a 100644 --- a/lib/crypto.js +++ b/lib/crypto.js @@ -263,7 +263,12 @@ Cipher.prototype._transform = function(chunk, encoding, callback) { }; Cipher.prototype._flush = function(callback) { - this.push(this._binding.final()); + try { + this.push(this._binding.final()); + } catch (e) { + callback(e); + return; + } callback(); }; -- cgit v1.2.3