From 10889924a536c3e3a839c00a31727d60f6d55756 Mon Sep 17 00:00:00 2001 From: Cody Peter Mello Date: Tue, 31 Jul 2018 20:32:14 +0000 Subject: [PATCH] joyent/node-sshpk#52 Buffer no longer performs length check for hex strings in node v8.x Reviewed by: Alex Wilson Approved by: Alex Wilson --- lib/fingerprint.js | 2 +- test/openssl-cmd.js | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/fingerprint.js b/lib/fingerprint.js index 4e75e66..62f3754 100644 --- a/lib/fingerprint.js +++ b/lib/fingerprint.js @@ -102,7 +102,7 @@ Fingerprint.parse = function (fp, options) { parts = parts.join(''); /*JSSTYLED*/ var md5RE = /^[a-fA-F0-9]+$/; - if (!md5RE.test(parts)) + if (!md5RE.test(parts) || md5RE.length % 2 !== 0) throw (new FingerprintFormatError(fp)); try { hash = Buffer.from(parts, 'hex'); diff --git a/test/openssl-cmd.js b/test/openssl-cmd.js index a78c795..d1472b6 100644 --- a/test/openssl-cmd.js +++ b/test/openssl-cmd.js @@ -212,7 +212,12 @@ function genTests() { var bufs = []; kid.stdout.on('data', bufs.push.bind(bufs)); kid.on('close', function (rc) { - t.equal(rc, 0); + t.equal(rc, 0, 'openssl exited 0'); + if (bufs.length === 0) { + t.fail('"openssl dgst" wrote no output'); + t.end(); + return; + } var output = Buffer.concat(bufs); var sig = sshpk.parseSignature(output, algo, 'asn1'); t.ok(sig);