[Pkg-javascript-commits] [node-asn1.js] 95/202: der: fix ASN.1 utctime padding regression

Bastien Roucariès rouca at moszumanska.debian.org
Thu Apr 20 19:18:57 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-asn1.js.

commit 44585f00f374de99ef082851d251e7e0a9230be4
Author: Fedor Indutny <fedor at indutny.com>
Date:   Mon May 18 16:17:06 2015 +0200

    der: fix ASN.1 utctime padding regression
---
 lib/asn1/encoders/der.js | 6 +++---
 test/ping-pong-test.js   | 4 ++++
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/lib/asn1/encoders/der.js b/lib/asn1/encoders/der.js
index 68ad4ab..dd0462c 100644
--- a/lib/asn1/encoders/der.js
+++ b/lib/asn1/encoders/der.js
@@ -116,7 +116,7 @@ DERNode.prototype._encodeObjid = function encodeObjid(id, values, relative) {
 };
 
 function two(num) {
-  if (num <= 10)
+  if (num < 10)
     return '0' + num;
   else
     return num;
@@ -128,7 +128,7 @@ DERNode.prototype._encodeTime = function encodeTime(time, tag) {
 
   if (tag === 'gentime') {
     str = [
-      date.getFullYear(),
+      two(date.getFullYear()),
       two(date.getUTCMonth() + 1),
       two(date.getUTCDate()),
       two(date.getUTCHours()),
@@ -138,7 +138,7 @@ DERNode.prototype._encodeTime = function encodeTime(time, tag) {
     ].join('');
   } else if (tag === 'utctime') {
     str = [
-      date.getFullYear() % 100,
+      two(date.getFullYear() % 100),
       two(date.getUTCMonth() + 1),
       two(date.getUTCDate()),
       two(date.getUTCHours()),
diff --git a/test/ping-pong-test.js b/test/ping-pong-test.js
index 4651823..1044168 100644
--- a/test/ping-pong-test.js
+++ b/test/ping-pong-test.js
@@ -47,6 +47,10 @@ describe('asn1.js ping/pong', function() {
       this.utctime();
     }, 1385921175000);
 
+    test('utctime regression', function() {
+      this.utctime();
+    }, 1414454400000);
+
     test('null', function() {
       this.null_();
     }, null);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-asn1.js.git



More information about the Pkg-javascript-commits mailing list