Bug #8664 » openssl.bug_8664.patch
ext/openssl/ossl_asn1.c (working copy) | ||
---|---|---|
{
|
||
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;
|
test/openssl/test_asn1.rb (working copy) | ||
---|---|---|
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*')
|
- « Previous
- 1
- 2
- Next »