diff --git a/libtasn1-4.8-long-oid.patch b/libtasn1-4.8-long-oid.patch new file mode 100644 index 0000000..5a6bcd8 --- /dev/null +++ b/libtasn1-4.8-long-oid.patch @@ -0,0 +1,416 @@ +diff --git a/lib/coding.c b/lib/coding.c +index 7821d85..7141df7 100644 +--- a/lib/coding.c ++++ b/lib/coding.c +@@ -337,7 +337,7 @@ _asn1_objectid_der (unsigned char *str, unsigned char *der, int *der_len) + int len_len, counter, k, first, max_len; + char *temp, *n_end, *n_start; + unsigned char bit7; +- unsigned long val, val1 = 0; ++ uint64_t val, val1 = 0; + int str_len = _asn1_strlen (str); + + max_len = *der_len; +@@ -355,7 +355,7 @@ _asn1_objectid_der (unsigned char *str, unsigned char *der, int *der_len) + while ((n_end = strchr (n_start, '.'))) + { + *n_end = 0; +- val = strtoul (n_start, NULL, 10); ++ val = _asn1_strtou64 (n_start, NULL, 10); + counter++; + + if (counter == 1) +@@ -369,7 +369,7 @@ _asn1_objectid_der (unsigned char *str, unsigned char *der, int *der_len) + else + { + first = 0; +- for (k = 4; k >= 0; k--) ++ for (k = sizeof(val); k >= 0; k--) + { + bit7 = (val >> (k * 7)) & 0x7F; + if (bit7 || first || !k) +diff --git a/lib/decoding.c b/lib/decoding.c +index cfe2322..2cd9ac3 100644 +--- a/lib/decoding.c ++++ b/lib/decoding.c +@@ -395,7 +396,7 @@ asn1_get_object_id_der (const unsigned char *der, int der_len, int *ret_len, + int len_len, len, k; + int leading; + char temp[LTOSTR_MAX_SIZE]; +- unsigned long val, val1; ++ uint64_t val, val1; + + *ret_len = 0; + if (str && str_size > 0) +diff --git a/lib/int.h b/lib/int.h +index f1f1302..7d2eea3 100644 +--- a/lib/int.h ++++ b/lib/int.h +@@ -118,6 +118,12 @@ extern const tag_and_class_st _asn1_tags[]; + #define _asn1_strcpy(a,b) strcpy((char *)a, (const char *)b) + #define _asn1_strcat(a,b) strcat((char *)a, (const char *)b) + ++#if SIZEOF_UNSIGNED_LONG_INT == 8 ++# define _asn1_strtou64(n,e,b) strtoul((const char *) n, e, b) ++#else ++# define _asn1_strtou64(n,e,b) strtoull((const char *) n, e, b) ++#endif ++ + #define MAX_LOG_SIZE 1024 /* maximum number of characters of a log message */ + + /* Define used for visiting trees. */ +diff --git a/lib/parser_aux.c b/lib/parser_aux.c +index 52700c6..2285b20 100644 +--- a/lib/parser_aux.c ++++ b/lib/parser_aux.c +@@ -549,9 +549,9 @@ _asn1_delete_list_and_nodes (void) + + + char * +-_asn1_ltostr (long v, char str[LTOSTR_MAX_SIZE]) ++_asn1_ltostr (int64_t v, char str[LTOSTR_MAX_SIZE]) + { +- long d, r; ++ int64_t d, r; + char temp[LTOSTR_MAX_SIZE]; + int count, k, start; + +diff --git a/lib/parser_aux.h b/lib/parser_aux.h +index 10b864b..9f91833 100644 +--- a/lib/parser_aux.h ++++ b/lib/parser_aux.h +@@ -54,7 +54,7 @@ void _asn1_delete_list_and_nodes (void); + + /* Max 64-bit integer length is 20 chars + 1 for sign + 1 for null termination */ + #define LTOSTR_MAX_SIZE 22 +-char *_asn1_ltostr (long v, char str[LTOSTR_MAX_SIZE]); ++char *_asn1_ltostr (int64_t v, char str[LTOSTR_MAX_SIZE]); + + asn1_node _asn1_find_up (asn1_node node); + +diff --git a/tests/Makefile.am b/tests/Makefile.am +index d637ce0..379525e 100644 +--- a/tests/Makefile.am ++++ b/tests/Makefile.am +@@ -54,13 +54,13 @@ MOSTLYCLEANFILES = Test_parser_ERROR.asn + check_PROGRAMS = Test_parser Test_tree Test_encoding Test_indefinite \ + Test_errors Test_simple Test_overflow Test_strings Test_choice \ + Test_encdec copynode coding-decoding2 strict-der Test_choice_ocsp \ +- ocsp-basic-response octet-string ++ ocsp-basic-response octet-string coding-long-oid object-id-decoding + + TESTS = Test_parser Test_tree Test_encoding Test_indefinite \ + Test_errors Test_simple Test_overflow crlf threadsafety \ + Test_strings Test_choice Test_encdec copynode coding-decoding2 \ + strict-der Test_choice_ocsp decoding decoding-invalid-x509 \ +- ocsp-basic-response octet-string ++ ocsp-basic-response octet-string coding-long-oid object-id-decoding + + TESTS_ENVIRONMENT = \ + ASN1PARSER=$(srcdir)/Test_parser.asn \ +diff --git a/tests/coding-long-oid.c b/tests/coding-long-oid.c +new file mode 100644 +index 0000000..bc2cd56 +--- /dev/null ++++ b/tests/coding-long-oid.c +@@ -0,0 +1,205 @@ ++/* ++ * Copyright (C) 2016 Free Software Foundation, Inc. ++ * ++ * This file is part of LIBTASN1. ++ * ++ * This program is free software: you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation, either version 3 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program. If not, see . ++ * ++ */ ++ ++#include ++#include ++#include ++#include ++ ++/* This checks the decoding and re-encoding of OIDs which contain elements ++ * >= 2^32 bits. ++ */ ++ ++const unsigned char der_data[] = ++ "\x30\x82\x06\xdc\x30\x82\x05\xc4\xa0\x03\x02\x01\x02\x02\x08\x35" ++ "\x73\x8c\xaf\x21\xea\xbd\x2d\x30\x0d\x06\x09\x2a\x86\x48\x86\xf7" ++ "\x0d\x01\x01\x05\x05\x00\x30\x81\x8e\x31\x0b\x30\x09\x06\x03\x55" ++ "\x04\x06\x13\x02\x55\x53\x31\x17\x30\x15\x06\x03\x55\x04\x08\x13" ++ "\x0e\x4e\x6f\x72\x74\x68\x20\x43\x61\x72\x6f\x6c\x69\x6e\x61\x31" ++ "\x10\x30\x0e\x06\x03\x55\x04\x07\x13\x07\x52\x61\x6c\x65\x69\x67" ++ "\x68\x31\x10\x30\x0e\x06\x03\x55\x04\x0a\x13\x07\x4b\x61\x74\x65" ++ "\x6c\x6c\x6f\x31\x14\x30\x12\x06\x03\x55\x04\x0b\x13\x0b\x53\x6f" ++ "\x6d\x65\x4f\x72\x67\x55\x6e\x69\x74\x31\x2c\x30\x2a\x06\x03\x55" ++ "\x04\x03\x13\x23\x73\x61\x74\x2d\x72\x32\x32\x30\x2d\x31\x30\x2e" ++ "\x6c\x61\x62\x2e\x65\x6e\x67\x2e\x72\x64\x75\x32\x2e\x72\x65\x64" ++ "\x68\x61\x74\x2e\x63\x6f\x6d\x30\x1e\x17\x0d\x31\x36\x30\x37\x30" ++ "\x31\x31\x38\x35\x34\x31\x37\x5a\x17\x0d\x34\x39\x31\x32\x30\x31" ++ "\x31\x33\x30\x30\x30\x30\x5a\x30\x2b\x31\x29\x30\x27\x06\x03\x55" ++ "\x04\x03\x13\x20\x38\x61\x38\x38\x38\x30\x31\x37\x35\x35\x61\x37" ++ "\x63\x39\x30\x37\x30\x31\x35\x35\x61\x37\x63\x66\x62\x65\x33\x36" ++ "\x30\x30\x30\x34\x30\x82\x01\x22\x30\x0d\x06\x09\x2a\x86\x48\x86" ++ "\xf7\x0d\x01\x01\x01\x05\x00\x03\x82\x01\x0f\x00\x30\x82\x01\x0a" ++ "\x02\x82\x01\x01\x00\xdc\x70\x8b\x9c\x84\xe9\x3e\x79\x8f\x03\xe5" ++ "\x5f\x21\xf0\x29\x9e\xd9\x94\x4e\x0f\x37\x45\x47\x42\xda\x2a\xe0" ++ "\xda\xf5\x8b\xfa\xe1\xf8\x62\x51\x14\x9d\x9e\xe0\xc7\x69\xd0\x3d" ++ "\xfc\x25\x2f\xb6\x10\x45\xbd\x0d\xbc\x92\x86\x54\xbb\x4e\x7d\xd4" ++ "\x92\x75\x65\xba\x48\xa4\x64\xa1\xeb\xf7\xe7\xdc\xc0\xd7\x0a\x5e" ++ "\x36\x13\x0e\x4e\x35\xcc\x2c\xc6\xf3\xe7\xe7\xe5\x32\x8a\x0c\xf7" ++ "\x47\x28\x7a\x02\xc2\x68\x66\x19\x3a\xba\xca\x31\xe2\xdd\x43\xbe" ++ "\x26\x4c\x80\x12\x0c\xae\x44\x40\xeb\x69\x7d\x9e\x58\xd3\xab\xaf" ++ "\x69\xe6\x54\xae\x7d\x80\xee\x2c\x10\xe9\xbb\x5e\x6b\x89\x15\x2e" ++ "\x2c\x72\x26\xba\x7f\xe5\xa3\x66\xc5\x98\xc6\x57\xbf\x05\x1e\x55" ++ "\x93\xa6\x16\x83\xa6\x88\x79\x8f\x4e\xb5\x7e\x70\xeb\xf0\xa9\xa6" ++ "\xd5\xf9\x1f\xe6\xab\x70\x06\x43\xe0\xde\x82\xad\x0e\x04\x17\x2b" ++ "\x69\x82\x40\x98\x84\x14\x00\x2a\xa2\xda\x61\x7b\x35\xac\x71\x05" ++ "\x43\x6f\x55\x3a\x28\x4b\xd1\xa4\xeb\x3b\xf5\x03\xc2\xf8\x3c\xfd" ++ "\x0a\xc4\x99\x1d\xa7\x7d\x08\x5c\xd1\x15\x70\x73\xb9\xdc\x5c\xf2" ++ "\xfe\x2c\xc6\x21\x8a\xbe\xbd\x52\x37\x64\x04\xe5\x06\x3e\xc6\x62" ++ "\xa1\xe9\x8e\xcb\xc1\x02\x03\x01\x00\x01\xa3\x82\x03\x9e\x30\x82" ++ "\x03\x9a\x30\x11\x06\x09\x60\x86\x48\x01\x86\xf8\x42\x01\x01\x04" ++ "\x04\x03\x02\x05\xa0\x30\x0b\x06\x03\x55\x1d\x0f\x04\x04\x03\x02" ++ "\x04\xb0\x30\x81\xc3\x06\x03\x55\x1d\x23\x04\x81\xbb\x30\x81\xb8" ++ "\x80\x14\xca\xca\x62\x86\x04\x05\xf0\xf5\x9b\x38\xd2\x2c\x3c\x8c" ++ "\x65\x0f\xc6\xba\xa5\x3c\xa1\x81\x94\xa4\x81\x91\x30\x81\x8e\x31" ++ "\x0b\x30\x09\x06\x03\x55\x04\x06\x13\x02\x55\x53\x31\x17\x30\x15" ++ "\x06\x03\x55\x04\x08\x13\x0e\x4e\x6f\x72\x74\x68\x20\x43\x61\x72" ++ "\x6f\x6c\x69\x6e\x61\x31\x10\x30\x0e\x06\x03\x55\x04\x07\x13\x07" ++ "\x52\x61\x6c\x65\x69\x67\x68\x31\x10\x30\x0e\x06\x03\x55\x04\x0a" ++ "\x13\x07\x4b\x61\x74\x65\x6c\x6c\x6f\x31\x14\x30\x12\x06\x03\x55" ++ "\x04\x0b\x13\x0b\x53\x6f\x6d\x65\x4f\x72\x67\x55\x6e\x69\x74\x31" ++ "\x2c\x30\x2a\x06\x03\x55\x04\x03\x13\x23\x73\x61\x74\x2d\x72\x32" ++ "\x32\x30\x2d\x31\x30\x2e\x6c\x61\x62\x2e\x65\x6e\x67\x2e\x72\x64" ++ "\x75\x32\x2e\x72\x65\x64\x68\x61\x74\x2e\x63\x6f\x6d\x82\x09\x00" ++ "\xa4\xe7\xca\xeb\xbe\x43\x5d\xcc\x30\x1d\x06\x03\x55\x1d\x0e\x04" ++ "\x16\x04\x14\x0e\x8d\x7b\x53\xba\x5a\x9e\x92\x44\xe5\x64\x58\xa1" ++ "\xdb\x83\x47\x05\x3e\x32\xd3\x30\x13\x06\x03\x55\x1d\x25\x04\x0c" ++ "\x30\x0a\x06\x08\x2b\x06\x01\x05\x05\x07\x03\x02\x30\x2a\x06\x10" ++ "\x2b\x06\x01\x04\x01\x92\x08\x09\x01\xaa\xda\xbe\xbe\xfa\x5b\x01" ++ "\x04\x16\x0c\x14\x6d\x6f\x72\x64\x6f\x72\x5f\x75\x65\x62\x65\x72" ++ "\x5f\x70\x72\x6f\x64\x75\x63\x74\x30\x16\x06\x10\x2b\x06\x01\x04" ++ "\x01\x92\x08\x09\x01\xaa\xda\xbe\xbe\xfa\x5b\x03\x04\x02\x0c\x00" ++ "\x30\x16\x06\x10\x2b\x06\x01\x04\x01\x92\x08\x09\x01\xaa\xda\xbe" ++ "\xbe\xfa\x5b\x02\x04\x02\x0c\x00\x30\x16\x06\x10\x2b\x06\x01\x04" ++ "\x01\x92\x08\x09\x01\xaa\xda\xbe\xbe\xfa\x5b\x05\x04\x02\x0c\x00" ++ "\x30\x19\x06\x10\x2b\x06\x01\x04\x01\x92\x08\x09\x02\xaa\xda\xbe" ++ "\xbe\xfa\x72\x01\x04\x05\x0c\x03\x79\x75\x6d\x30\x24\x06\x11\x2b" ++ "\x06\x01\x04\x01\x92\x08\x09\x02\xaa\xda\xbe\xbe\xfa\x72\x01\x01" ++ "\x04\x0f\x0c\x0d\x75\x65\x62\x65\x72\x5f\x63\x6f\x6e\x74\x65\x6e" ++ "\x74\x30\x32\x06\x11\x2b\x06\x01\x04\x01\x92\x08\x09\x02\xaa\xda" ++ "\xbe\xbe\xfa\x72\x01\x02\x04\x1d\x0c\x1b\x31\x34\x36\x37\x33\x39" ++ "\x39\x32\x35\x37\x34\x33\x35\x5f\x75\x65\x62\x65\x72\x5f\x63\x6f" ++ "\x6e\x74\x65\x6e\x74\x30\x1d\x06\x11\x2b\x06\x01\x04\x01\x92\x08" ++ "\x09\x02\xaa\xda\xbe\xbe\xfa\x72\x01\x05\x04\x08\x0c\x06\x43\x75" ++ "\x73\x74\x6f\x6d\x30\x1e\x06\x11\x2b\x06\x01\x04\x01\x92\x08\x09" ++ "\x02\xaa\xda\xbe\xbe\xfa\x72\x01\x06\x04\x09\x0c\x07\x2f\x6d\x6f" ++ "\x72\x64\x6f\x72\x30\x17\x06\x11\x2b\x06\x01\x04\x01\x92\x08\x09" ++ "\x02\xaa\xda\xbe\xbe\xfa\x72\x01\x07\x04\x02\x0c\x00\x30\x18\x06" ++ "\x11\x2b\x06\x01\x04\x01\x92\x08\x09\x02\xaa\xda\xbe\xbe\xfa\x72" ++ "\x01\x08\x04\x03\x0c\x01\x31\x30\x24\x06\x0a\x2b\x06\x01\x04\x01" ++ "\x92\x08\x09\x04\x01\x04\x16\x0c\x14\x6d\x6f\x72\x64\x6f\x72\x5f" ++ "\x75\x65\x62\x65\x72\x5f\x70\x72\x6f\x64\x75\x63\x74\x30\x10\x06" ++ "\x0a\x2b\x06\x01\x04\x01\x92\x08\x09\x04\x02\x04\x02\x0c\x00\x30" ++ "\x1d\x06\x0a\x2b\x06\x01\x04\x01\x92\x08\x09\x04\x03\x04\x0f\x0c" ++ "\x0d\x31\x34\x36\x37\x33\x39\x39\x32\x35\x37\x34\x33\x35\x30\x11" ++ "\x06\x0a\x2b\x06\x01\x04\x01\x92\x08\x09\x04\x05\x04\x03\x0c\x01" ++ "\x31\x30\x24\x06\x0a\x2b\x06\x01\x04\x01\x92\x08\x09\x04\x06\x04" ++ "\x16\x0c\x14\x32\x30\x31\x36\x2d\x30\x37\x2d\x30\x31\x54\x31\x38" ++ "\x3a\x35\x34\x3a\x31\x37\x5a\x30\x24\x06\x0a\x2b\x06\x01\x04\x01" ++ "\x92\x08\x09\x04\x07\x04\x16\x0c\x14\x32\x30\x34\x39\x2d\x31\x32" ++ "\x2d\x30\x31\x54\x31\x33\x3a\x30\x30\x3a\x30\x30\x5a\x30\x11\x06" ++ "\x0a\x2b\x06\x01\x04\x01\x92\x08\x09\x04\x0c\x04\x03\x0c\x01\x30" ++ "\x30\x11\x06\x0a\x2b\x06\x01\x04\x01\x92\x08\x09\x04\x0e\x04\x03" ++ "\x0c\x01\x30\x30\x11\x06\x0a\x2b\x06\x01\x04\x01\x92\x08\x09\x04" ++ "\x0b\x04\x03\x0c\x01\x31\x30\x34\x06\x0a\x2b\x06\x01\x04\x01\x92" ++ "\x08\x09\x05\x01\x04\x26\x0c\x24\x39\x34\x35\x33\x66\x38\x65\x36" ++ "\x2d\x38\x34\x62\x32\x2d\x34\x38\x32\x65\x2d\x61\x33\x65\x61\x2d" ++ "\x30\x31\x63\x33\x62\x33\x65\x32\x36\x36\x61\x35\x30\x0d\x06\x09" ++ "\x2a\x86\x48\x86\xf7\x0d\x01\x01\x05\x05\x00\x03\x82\x01\x01\x00" ++ "\xf7\x4d\xf3\x30\x53\xcd\x35\xbf\x49\x07\x29\x9b\xf0\x7a\xaa\x49" ++ "\x60\xda\xce\x14\x45\xb5\x32\x8f\xda\xc3\xce\x6b\xec\xbf\x20\xc0" ++ "\x05\xa3\x3a\x89\xc4\x7d\x66\x34\xfc\xf3\x16\xb8\xf3\x03\xda\xfc" ++ "\x82\x4a\xb8\x97\xf8\x67\x3d\xc2\x8c\x78\xb4\x6d\xb8\xbb\x18\xec" ++ "\x36\xee\xc4\x28\x79\xda\xfe\xa1\x1f\xaf\x0b\x3f\xe4\x75\xde\x83" ++ "\xff\x6b\xf9\x11\x60\x09\x57\xea\x85\x34\xed\x60\xe2\x94\x8b\xd6" ++ "\xf2\x21\x9b\xda\x97\x99\xf3\x0d\xa9\x0f\xb5\x3b\x3a\x8f\x96\x8d" ++ "\x0b\xdf\x30\x17\x03\xe6\x47\xc3\x71\x32\x09\x18\xbc\xc0\xa9\x83" ++ "\x7e\xb7\x5f\x5c\xbb\xeb\x0a\x18\x3f\xa9\x40\x98\xae\x57\xab\x99" ++ "\x3d\x47\x1b\x98\x8a\xdc\x6e\x85\xa2\xea\x5e\x21\x80\xa9\xb5\x48" ++ "\xc9\x1d\x63\xc1\x1b\xe6\x01\xa1\xbd\x84\x38\x7f\x1a\x43\xa5\xd4" ++ "\x7f\x41\x5b\xf6\x88\x33\xb0\xf1\xb8\x8f\xe1\x39\x69\x6f\x60\x13" ++ "\xd3\x5d\x70\xde\x95\x0d\x2f\xa9\x89\x6c\xd4\x3a\xeb\x22\x59\xe6" ++ "\x31\x67\x71\xa5\xed\xfb\xcb\x20\x11\x0c\x31\x2e\xe0\x98\x9a\x3b" ++ "\x9c\x7b\xa2\x74\x6f\x87\x97\xa1\xd9\x82\x7f\x7d\x62\x6b\x45\x6c" ++ "\x0b\x5e\x25\x43\x8a\x20\x16\x7d\xe5\x84\x18\x3f\x7c\xda\xfc\xf9"; ++ ++int der_data_size = sizeof(der_data)-1; ++ ++char new_data[4*1024]; ++ ++int ++main (int argc, char** argv) ++{ ++ int result = 0; ++ asn1_node definitions = NULL, node1 = NULL; ++ char errorDescription[ASN1_MAX_ERROR_DESCRIPTION_SIZE]; ++ const char *pkixfile = getenv ("ASN1PKIX"); ++ int new_data_size; ++ ++ if (!pkixfile) ++ pkixfile = "pkix.asn"; ++ ++ /* Encode */ ++ result = asn1_parser2tree (pkixfile, &definitions, errorDescription); ++ if (result != ASN1_SUCCESS) ++ { ++ printf ("error in %d\n", __LINE__); ++ exit (1); ++ } ++ ++ result = asn1_create_element (definitions, "PKIX1.Certificate", &node1); ++ if (result != ASN1_SUCCESS) ++ { ++ printf ("error in %d\n", __LINE__); ++ exit (1); ++ } ++ ++ result = asn1_der_decoding (&node1, der_data, der_data_size, errorDescription); ++ if (result != ASN1_SUCCESS) ++ { ++ printf ("error in %d: %s\n", __LINE__, errorDescription); ++ exit (1); ++ } ++ ++ new_data_size = sizeof(new_data); ++ result = asn1_der_coding (node1, "", new_data, &new_data_size, errorDescription); ++ if (result != ASN1_SUCCESS) ++ { ++ printf ("error in %d\n", __LINE__); ++ exit (1); ++ } ++ ++ if (new_data_size != der_data_size) ++ { ++ printf ("error in %d\n", __LINE__); ++ printf ("new_size is %d, expected: %d\n", new_data_size, der_data_size); ++ exit (1); ++ } ++ ++ if (memcmp(new_data, der_data, der_data_size) != 0) ++ { ++ printf ("error in %d\n", __LINE__); ++ exit (1); ++ } ++ ++ asn1_delete_structure (&node1); ++ asn1_delete_structure (&definitions); ++ ++ return 0; ++} +diff --git a/tests/object-id-decoding.c b/tests/object-id-decoding.c +new file mode 100644 +index 0000000..e3e9669 +--- /dev/null ++++ b/tests/object-id-decoding.c +@@ -0,0 +1,89 @@ ++/* ++ * Copyright (C) 2016 Red Hat, Inc. ++ * ++ * This file is part of LIBTASN1. ++ * ++ * This program is free software: you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation, either version 3 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program. If not, see . ++ * ++ */ ++ ++#include ++#include ++#include ++ ++#include "libtasn1.h" ++ ++struct tv ++{ ++ int der_len; ++ const unsigned char *der_str; ++ const char *oid; ++ int expected_error; ++}; ++ ++static const struct tv tv[] = { ++ {.der_len = 12, ++ .der_str = (void *) "\x06\x0a\x2b\x06\x01\x04\x01\x92\x08\x09\x05\x01", ++ .oid = "1.3.6.1.4.1.2312.9.5.1", ++ .expected_error = ASN1_SUCCESS}, ++ {.der_len = 19, ++ .der_str = ++ (void *) ++ "\x06\x11\x2b\x06\x01\x04\x01\x92\x08\x09\x02\xaa\xda\xbe\xbe\xfa\x72\x01\x07", ++ .oid = "1.3.6.1.4.1.2312.9.2.1467399257458.1.7", ++ .expected_error = ASN1_SUCCESS}, ++}; ++ ++int ++main (int argc, char *argv[]) ++{ ++ char str[128]; ++ int ret, ret_len; ++ size_t i; ++ ++ for (i = 0; i < sizeof (tv) / sizeof (tv[0]); i++) ++ { ++ /* decode */ ++ ret = ++ asn1_get_object_id_der (tv[i].der_str+1, ++ tv[i].der_len-1, &ret_len, str, ++ sizeof (str)); ++ if (ret != tv[i].expected_error) ++ { ++ fprintf (stderr, ++ "%d: asn1_get_object_id_der iter %lu: got %d expected %d\n", ++ __LINE__, (unsigned long) i, ret, tv[i].expected_error); ++ return 1; ++ } ++ ++ if (ret_len != tv[i].der_len-1) ++ { ++ fprintf (stderr, ++ "%d: iter %lu: error in DER, length returned is %d, had %d\n", ++ __LINE__, (unsigned long)i, ret_len, tv[i].der_len-1); ++ return 1; ++ } ++ ++ if (strcmp (tv[i].oid, str) != 0) ++ { ++ fprintf (stderr, ++ "%d: strcmp iter %lu: got invalid OID: %s, expected: %s\n", ++ __LINE__, (unsigned long) i, str, tv[i].oid); ++ return 1; ++ } ++ ++ } ++ ++ return 0; ++} diff --git a/libtasn1.spec b/libtasn1.spec index f5f9d0c..ec46882 100644 --- a/libtasn1.spec +++ b/libtasn1.spec @@ -1,7 +1,7 @@ Summary: The ASN.1 library used in GNUTLS Name: libtasn1 Version: 4.8 -Release: 1%{?dist} +Release: 2%{?dist} # The libtasn1 library is LGPLv2+, utilities are GPLv3+ License: GPLv3+ and LGPLv2+ @@ -11,7 +11,9 @@ Source0: http://ftp.gnu.org/gnu/libtasn1/%name-%version.tar.gz Source1: http://ftp.gnu.org/gnu/libtasn1/%name-%version.tar.gz.sig Source2: gpgkey-1F42418905D8206AA754CCDC29EE58B996865171.gpg Patch1: libtasn1-3.4-rpath.patch +Patch2: libtasn1-4.8-long-oid.patch BuildRequires: bison, pkgconfig +BuildRequires: autoconf, automake, libtool %ifarch %ix86 x86_64 ppc ppc64 BuildRequires: valgrind %endif @@ -54,8 +56,10 @@ gpgv2 --keyring %{SOURCE2} %{SOURCE1} %{SOURCE0} %setup -q %patch1 -p1 -b .rpath +%patch2 -p1 -b .long-oid %build +autoreconf -v -f --install %configure --disable-static --disable-silent-rules --disable-valgrind-tests # libtasn1 likes to regenerate docs touch doc/stamp_docs @@ -108,6 +112,9 @@ test "$1" = 0 -a -f %_infodir/%name.info.gz && \ %changelog +* Fri Jul 8 2016 Nikos Mavrogiannopoulos - 4.8-2 +- Resolve issue which prevented the decoding of long OIDs (#1353838) + * Mon Apr 11 2016 Nikos Mavrogiannopoulos - 4.8-1 - Update to 4.8 - Resolves infinite loop recursion in the decode of certain BER structures.