[前][次][番号順一覧][スレッド一覧]

ruby-changes:30276

From: usa <ko1@a...>
Date: Fri, 2 Aug 2013 20:49:41 +0900 (JST)
Subject: [ruby-changes:30276] usa:r42328 (ruby_1_9_3): merge revision(s) 42126: [Backport #8664]

usa	2013-08-02 20:49:29 +0900 (Fri, 02 Aug 2013)

  New Revision: 42328

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42328

  Log:
    merge revision(s) 42126: [Backport #8664]
    
    * ext/openssl/ossl_asn1.c (asn1time_to_time):  Implement YYMMDDhhmmZ
      format for ASN.1 UTCTime.  [ruby-trunk - Bug #8664]
    
    * test/openssl/test_asn1.rb:  Test for the above.

  Modified directories:
    branches/ruby_1_9_3/
  Modified files:
    branches/ruby_1_9_3/ChangeLog
    branches/ruby_1_9_3/ext/openssl/ossl_asn1.c
    branches/ruby_1_9_3/test/openssl/test_asn1.rb
    branches/ruby_1_9_3/version.h

Index: ruby_1_9_3/ChangeLog
===================================================================
--- ruby_1_9_3/ChangeLog	(revision 42327)
+++ ruby_1_9_3/ChangeLog	(revision 42328)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ChangeLog#L1
+Fri Aug  2 20:41:15 2013  Eric Hodel  <drbrain@s...>
+
+	* ext/openssl/ossl_asn1.c (asn1time_to_time):  Implement YYMMDDhhmmZ
+	  format for ASN.1 UTCTime.  [ruby-trunk - Bug #8664]
+	* test/openssl/test_asn1.rb:  Test for the above.
+
 Fri Aug  2 20:34:06 2013  Masaki Matsushita  <glass.saga@g...>
 
 	* io.c (io_getpartial): use rb_str_locktmp_ensure().
Index: ruby_1_9_3/ext/openssl/ossl_asn1.c
===================================================================
--- ruby_1_9_3/ext/openssl/ossl_asn1.c	(revision 42327)
+++ ruby_1_9_3/ext/openssl/ossl_asn1.c	(revision 42328)
@@ -33,15 +33,22 @@ asn1time_to_time(ASN1_TIME *time) https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ext/openssl/ossl_asn1.c#L33
 {
     struct tm tm;
     VALUE argv[6];
+    int count;
 
     if (!time || !time->data) return Qnil;
     memset(&tm, 0, sizeof(struct tm));
 
     switch (time->type) {
     case V_ASN1_UTCTIME:
-	if (sscanf((const char *)time->data, "%2d%2d%2d%2d%2d%2dZ", &tm.tm_year, &tm.tm_mon,
-    		&tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 6) {
-	    ossl_raise(rb_eTypeError, "bad UTCTIME format");
+	count = sscanf((const char *)time->data, "%2d%2d%2d%2d%2d%2dZ",
+		&tm.tm_year, &tm.tm_mon, &tm.tm_mday, &tm.tm_hour, &tm.tm_min,
+		&tm.tm_sec);
+
+	if (count == 5) {
+	    tm.tm_sec = 0;
+	} else if (count != 6) {
+	    ossl_raise(rb_eTypeError, "bad UTCTIME format: \"%s\"",
+		    time->data);
 	}
 	if (tm.tm_year < 69) {
 	    tm.tm_year += 2000;
Index: ruby_1_9_3/version.h
===================================================================
--- ruby_1_9_3/version.h	(revision 42327)
+++ ruby_1_9_3/version.h	(revision 42328)
@@ -1,5 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/version.h#L1
 #define RUBY_VERSION "1.9.3"
-#define RUBY_PATCHLEVEL 457
+#define RUBY_PATCHLEVEL 458
 
 #define RUBY_RELEASE_DATE "2013-08-02"
 #define RUBY_RELEASE_YEAR 2013
Index: ruby_1_9_3/test/openssl/test_asn1.rb
===================================================================
--- ruby_1_9_3/test/openssl/test_asn1.rb	(revision 42327)
+++ ruby_1_9_3/test/openssl/test_asn1.rb	(revision 42328)
@@ -263,6 +263,14 @@ rEzBQ0F9dUyqQ9gyRg8KHhDfv9HzT1d/rnUZMkoo https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/test/openssl/test_asn1.rb#L263
     end
   end
 
+  def test_decode_utctime
+    expected = Time.at 1374535380
+    assert_equal expected, OpenSSL::ASN1.decode("\x17\v1307222323Z").value
+
+    expected += 17
+    assert_equal expected, OpenSSL::ASN1.decode("\x17\r130722232317Z").value
+  end
+
   def test_create_inf_length_primitive
     expected = %w{ 24 80 04 01 61 00 00 }
     raw = [expected.join('')].pack('H*')

Property changes on: ruby_1_9_3
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r42126


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]