diff options
author | Simon Josefsson <simon@josefsson.org> | 2008-04-21 12:58:59 +0200 |
---|---|---|
committer | Simon Josefsson <simon@josefsson.org> | 2008-04-21 12:58:59 +0200 |
commit | 516d61d7ca700f01e091a16ef966354393cb35f9 (patch) | |
tree | 70229cf4baad4896eb5ea08bd5baf05e31bf5ce3 /lib | |
parent | 2bc2c9a09598b587c6d08d8d4f1376c75a177c2d (diff) | |
download | gnutls-516d61d7ca700f01e091a16ef966354393cb35f9.tar.gz |
Update to libtasn1 1.4.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/minitasn1/Makefile.am | 2 | ||||
-rw-r--r-- | lib/minitasn1/coding.c | 22 | ||||
-rw-r--r-- | lib/minitasn1/decoding.c | 22 | ||||
-rw-r--r-- | lib/minitasn1/element.c | 38 | ||||
-rw-r--r-- | lib/minitasn1/int.h | 6 | ||||
-rw-r--r-- | lib/minitasn1/libtasn1.h | 4 | ||||
-rw-r--r-- | lib/minitasn1/mem.h | 27 |
7 files changed, 49 insertions, 72 deletions
diff --git a/lib/minitasn1/Makefile.am b/lib/minitasn1/Makefile.am index df8892d6bb..371a1d2555 100644 --- a/lib/minitasn1/Makefile.am +++ b/lib/minitasn1/Makefile.am @@ -2,7 +2,7 @@ INCLUDES = -I$(top_srcdir)/lib -I$(top_srcdir)/lgl -I$(top_builddir)/lgl noinst_LTLIBRARIES = libminitasn1.la -libminitasn1_la_SOURCES = libtasn1.h mem.h gstr.h errors.h int.h \ +libminitasn1_la_SOURCES = libtasn1.h gstr.h errors.h int.h \ parser_aux.h structure.h element.h decoding.c gstr.c errors.c \ parser_aux.c structure.c element.c coding.c diff --git a/lib/minitasn1/coding.c b/lib/minitasn1/coding.c index cd646c7822..74c83904ec 100644 --- a/lib/minitasn1/coding.c +++ b/lib/minitasn1/coding.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2006 Free Software Foundation + * Copyright (C) 2004, 2006, 2008 Free Software Foundation * Copyright (C) 2002 Fabio Fiorina * * This file is part of LIBTASN1. @@ -260,7 +260,7 @@ _asn1_objectid_der (unsigned char *str, unsigned char *der, int *der_len) max_len = *der_len; - temp = (char *) _asn1_alloca (strlen (str) + 2); + temp = (char *) _asn1_malloc (strlen (str) + 2); if (temp == NULL) return ASN1_MEM_ALLOC_ERROR; @@ -312,7 +312,7 @@ _asn1_objectid_der (unsigned char *str, unsigned char *der, int *der_len) } *der_len += len_len; - _asn1_afree (temp); + _asn1_free (temp); if (max_len < (*der_len)) return ASN1_MEM_ERROR; @@ -636,7 +636,7 @@ _asn1_ordering_set (unsigned char *der, int der_len, node_asn * node) first = last = NULL; while (p) { - p_vet = (struct vet *) _asn1_alloca (sizeof (struct vet)); + p_vet = (struct vet *) _asn1_malloc (sizeof (struct vet)); if (p_vet == NULL) return; @@ -677,7 +677,7 @@ _asn1_ordering_set (unsigned char *der, int der_len, node_asn * node) if (p_vet->value > p2_vet->value) { /* change position */ - temp = (unsigned char *) _asn1_alloca (p_vet->end - counter); + temp = (unsigned char *) _asn1_malloc (p_vet->end - counter); if (temp == NULL) return; @@ -686,7 +686,7 @@ _asn1_ordering_set (unsigned char *der, int der_len, node_asn * node) p2_vet->end - p_vet->end); memcpy (der + counter + p2_vet->end - p_vet->end, temp, p_vet->end - counter); - _asn1_afree (temp); + _asn1_free (temp); tag = p_vet->value; p_vet->value = p2_vet->value; @@ -704,7 +704,7 @@ _asn1_ordering_set (unsigned char *der, int der_len, node_asn * node) p_vet->prev->next = NULL; else first = NULL; - _asn1_afree (p_vet); + _asn1_free (p_vet); p_vet = first; } } @@ -750,7 +750,7 @@ _asn1_ordering_set_of (unsigned char *der, int der_len, node_asn * node) first = last = NULL; while (p) { - p_vet = (struct vet *) _asn1_alloca (sizeof (struct vet)); + p_vet = (struct vet *) _asn1_malloc (sizeof (struct vet)); if (p_vet == NULL) return; @@ -815,7 +815,7 @@ _asn1_ordering_set_of (unsigned char *der, int der_len, node_asn * node) if (change == 1) { /* change position */ - temp = (unsigned char *) _asn1_alloca (p_vet->end - counter); + temp = (unsigned char *) _asn1_malloc (p_vet->end - counter); if (temp == NULL) return; @@ -824,7 +824,7 @@ _asn1_ordering_set_of (unsigned char *der, int der_len, node_asn * node) (p2_vet->end) - (p_vet->end)); memcpy (der + counter + (p2_vet->end) - (p_vet->end), temp, (p_vet->end) - counter); - _asn1_afree (temp); + _asn1_free (temp); p_vet->end = counter + (p2_vet->end - p_vet->end); } @@ -838,7 +838,7 @@ _asn1_ordering_set_of (unsigned char *der, int der_len, node_asn * node) p_vet->prev->next = NULL; else first = NULL; - _asn1_afree (p_vet); + _asn1_free (p_vet); p_vet = first; } } diff --git a/lib/minitasn1/decoding.c b/lib/minitasn1/decoding.c index 5d51a4e37f..c1de9e6773 100644 --- a/lib/minitasn1/decoding.c +++ b/lib/minitasn1/decoding.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2006 Free Software Foundation + * Copyright (C) 2004, 2006, 2008 Free Software Foundation * Copyright (C) 2002 Fabio Fiorina * * This file is part of LIBTASN1. @@ -618,7 +618,7 @@ _asn1_get_octet_string (const unsigned char *der, node_asn * node, int *len) if (node) { asn1_length_der (tot_len, NULL, &len2); - temp = _asn1_alloca (len2 + tot_len); + temp = _asn1_malloc (len2 + tot_len); if (temp == NULL) { return ASN1_MEM_ALLOC_ERROR; @@ -653,7 +653,7 @@ _asn1_get_octet_string (const unsigned char *der, node_asn * node, int *len) } _asn1_set_value (node, temp, tot_len); - _asn1_afree (temp); + _asn1_free (temp); } } else @@ -1193,7 +1193,7 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, { len2 += len4; asn1_length_der (len2 + len3, NULL, &len4); - temp2 = (unsigned char *) _asn1_alloca (len2 + len3 + len4); + temp2 = (unsigned char *) _asn1_malloc (len2 + len3 + len4); if (temp2 == NULL) { asn1_delete_structure (element); @@ -1202,7 +1202,7 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, asn1_octet_der (der + counter, len2 + len3, temp2, &len4); _asn1_set_value (p, temp2, len4); - _asn1_afree (temp2); + _asn1_free (temp2); counter += len2 + len3; } else @@ -1222,7 +1222,7 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, return ris; } asn1_length_der (len2, NULL, &len4); - temp2 = (unsigned char *) _asn1_alloca (len2 + len4); + temp2 = (unsigned char *) _asn1_malloc (len2 + len4); if (temp2 == NULL) { asn1_delete_structure (element); @@ -1231,7 +1231,7 @@ asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, asn1_octet_der (der + counter, len2, temp2, &len4); _asn1_set_value (p, temp2, len4); - _asn1_afree (temp2); + _asn1_free (temp2); counter += len2; /* Check if a couple of 0x00 are present due to an EXPLICIT TAG with @@ -1879,7 +1879,7 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName, { asn1_length_der (len2 + len3, NULL, &len4); temp2 = - (unsigned char *) _asn1_alloca (len2 + len3 + len4); + (unsigned char *) _asn1_malloc (len2 + len3 + len4); if (temp2 == NULL) { asn1_delete_structure (structure); @@ -1889,7 +1889,7 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName, asn1_octet_der (der + counter, len2 + len3, temp2, &len4); _asn1_set_value (p, temp2, len4); - _asn1_afree (temp2); + _asn1_free (temp2); if (p == nodeFound) state = EXIT; @@ -1916,7 +1916,7 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName, if (state == FOUND) { asn1_length_der (len2, NULL, &len4); - temp2 = (unsigned char *) _asn1_alloca (len2 + len4); + temp2 = (unsigned char *) _asn1_malloc (len2 + len4); if (temp2 == NULL) { asn1_delete_structure (structure); @@ -1925,7 +1925,7 @@ asn1_der_decoding_element (ASN1_TYPE * structure, const char *elementName, asn1_octet_der (der + counter, len2, temp2, &len4); _asn1_set_value (p, temp2, len4); - _asn1_afree (temp2); + _asn1_free (temp2); if (p == nodeFound) state = EXIT; diff --git a/lib/minitasn1/element.c b/lib/minitasn1/element.c index fd66f248aa..752b40da85 100644 --- a/lib/minitasn1/element.c +++ b/lib/minitasn1/element.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2006 Free Software Foundation + * Copyright (C) 2004, 2006, 2008 Free Software Foundation * Copyright (C) 2000, 2001, 2002, 2003 Fabio Fiorina * * This file is part of LIBTASN1. @@ -350,7 +350,7 @@ asn1_write_value (ASN1_TYPE node_root, const char *name, if ((isdigit (value[0])) || (value[0] == '-')) { value_temp = - (unsigned char *) _asn1_alloca (SIZEOF_UNSIGNED_LONG_INT); + (unsigned char *) _asn1_malloc (SIZEOF_UNSIGNED_LONG_INT); if (value_temp == NULL) return ASN1_MEM_ALLOC_ERROR; @@ -370,7 +370,7 @@ asn1_write_value (ASN1_TYPE node_root, const char *name, { value_temp = (unsigned char *) - _asn1_alloca (SIZEOF_UNSIGNED_LONG_INT); + _asn1_malloc (SIZEOF_UNSIGNED_LONG_INT); if (value_temp == NULL) return ASN1_MEM_ALLOC_ERROR; @@ -389,7 +389,7 @@ asn1_write_value (ASN1_TYPE node_root, const char *name, } else { /* len != 0 */ - value_temp = (unsigned char *) _asn1_alloca (len); + value_temp = (unsigned char *) _asn1_malloc (len); if (value_temp == NULL) return ASN1_MEM_ALLOC_ERROR; memcpy (value_temp, value, len); @@ -403,7 +403,7 @@ asn1_write_value (ASN1_TYPE node_root, const char *name, if (negative && (type_field (node->type) == TYPE_ENUMERATED)) { - _asn1_afree (value_temp); + _asn1_free (value_temp); return ASN1_VALUE_NOT_VALID; } @@ -418,14 +418,14 @@ asn1_write_value (ASN1_TYPE node_root, const char *name, k--; asn1_length_der (len - k, NULL, &len2); - temp = (unsigned char *) _asn1_alloca (len - k + len2); + temp = (unsigned char *) _asn1_malloc (len - k + len2); if (temp == NULL) return ASN1_MEM_ALLOC_ERROR; asn1_octet_der (value_temp + k, len - k, temp, &len2); _asn1_set_value (node, temp, len2); - _asn1_afree (temp); + _asn1_free (temp); if (node->type & CONST_DEFAULT) @@ -436,7 +436,7 @@ asn1_write_value (ASN1_TYPE node_root, const char *name, if ((isdigit (p->value[0])) || (p->value[0] == '-')) { default_temp = - (unsigned char *) _asn1_alloca (SIZEOF_UNSIGNED_LONG_INT); + (unsigned char *) _asn1_malloc (SIZEOF_UNSIGNED_LONG_INT); if (default_temp == NULL) return ASN1_MEM_ALLOC_ERROR; @@ -456,7 +456,7 @@ asn1_write_value (ASN1_TYPE node_root, const char *name, { default_temp = (unsigned char *) - _asn1_alloca (SIZEOF_UNSIGNED_LONG_INT); + _asn1_malloc (SIZEOF_UNSIGNED_LONG_INT); if (default_temp == NULL) return ASN1_MEM_ALLOC_ERROR; @@ -484,9 +484,9 @@ asn1_write_value (ASN1_TYPE node_root, const char *name, if (k2 == len2) _asn1_set_value (node, NULL, 0); } - _asn1_afree (default_temp); + _asn1_free (default_temp); } - _asn1_afree (value_temp); + _asn1_free (value_temp); break; case TYPE_OBJECT_ID: for (k = 0; k < strlen (value); k++) @@ -555,37 +555,37 @@ asn1_write_value (ASN1_TYPE node_root, const char *name, if (len == 0) len = strlen (value); asn1_length_der (len, NULL, &len2); - temp = (unsigned char *) _asn1_alloca (len + len2); + temp = (unsigned char *) _asn1_malloc (len + len2); if (temp == NULL) return ASN1_MEM_ALLOC_ERROR; asn1_octet_der (value, len, temp, &len2); _asn1_set_value (node, temp, len2); - _asn1_afree (temp); + _asn1_free (temp); break; case TYPE_GENERALSTRING: if (len == 0) len = strlen (value); asn1_length_der (len, NULL, &len2); - temp = (unsigned char *) _asn1_alloca (len + len2); + temp = (unsigned char *) _asn1_malloc (len + len2); if (temp == NULL) return ASN1_MEM_ALLOC_ERROR; asn1_octet_der (value, len, temp, &len2); _asn1_set_value (node, temp, len2); - _asn1_afree (temp); + _asn1_free (temp); break; case TYPE_BIT_STRING: if (len == 0) len = strlen (value); asn1_length_der ((len >> 3) + 2, NULL, &len2); - temp = (unsigned char *) _asn1_alloca ((len >> 3) + 2 + len2); + temp = (unsigned char *) _asn1_malloc ((len >> 3) + 2 + len2); if (temp == NULL) return ASN1_MEM_ALLOC_ERROR; asn1_bit_der (value, len, temp, &len2); _asn1_set_value (node, temp, len2); - _asn1_afree (temp); + _asn1_free (temp); break; case TYPE_CHOICE: p = node->down; @@ -613,13 +613,13 @@ asn1_write_value (ASN1_TYPE node_root, const char *name, break; case TYPE_ANY: asn1_length_der (len, NULL, &len2); - temp = (unsigned char *) _asn1_alloca (len + len2); + temp = (unsigned char *) _asn1_malloc (len + len2); if (temp == NULL) return ASN1_MEM_ALLOC_ERROR; asn1_octet_der (value, len, temp, &len2); _asn1_set_value (node, temp, len2); - _asn1_afree (temp); + _asn1_free (temp); break; case TYPE_SEQUENCE_OF: case TYPE_SET_OF: diff --git a/lib/minitasn1/int.h b/lib/minitasn1/int.h index 5c897151a5..0c9c06f979 100644 --- a/lib/minitasn1/int.h +++ b/lib/minitasn1/int.h @@ -45,7 +45,11 @@ #define LIBTASN1_DEBUG_INTEGER */ -#include <mem.h> +#define _asn1_malloc malloc +#define _asn1_free free +#define _asn1_calloc calloc +#define _asn1_realloc realloc +#define _asn1_strdup strdup #define MAX_LOG_SIZE 1024 /* maximum number of characters of a log message */ diff --git a/lib/minitasn1/libtasn1.h b/lib/minitasn1/libtasn1.h index 8a192e4f46..fd35867367 100644 --- a/lib/minitasn1/libtasn1.h +++ b/lib/minitasn1/libtasn1.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2006 Free Software Foundation + * Copyright (C) 2004, 2005, 2006, 2008 Free Software Foundation * Copyright (C) 2002 Fabio Fiorina * * This file is part of LIBTASN1. @@ -31,7 +31,7 @@ extern "C" { #endif -#define LIBTASN1_VERSION "1.3" +#define LIBTASN1_VERSION "1.4" #include <sys/types.h> #include <time.h> diff --git a/lib/minitasn1/mem.h b/lib/minitasn1/mem.h deleted file mode 100644 index 267f62f311..0000000000 --- a/lib/minitasn1/mem.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef MEM_H -# define MEM_H - -/* Use _asn1_afree() when calling alloca, or - * memory leaks may occur in systems which do not - * support alloca. - */ -#ifdef HAVE_ALLOCA -# ifdef HAVE_ALLOCA_H -# include <alloca.h> -# endif -# define _asn1_alloca alloca -# define _asn1_afree(x) -#else -# define _asn1_alloca _asn1_malloc -# define _asn1_afree _asn1_free -#endif /* HAVE_ALLOCA */ - -#define _asn1_malloc malloc -#define _asn1_free free -#define _asn1_calloc calloc -#define _asn1_realloc realloc -#define _asn1_strdup strdup - -#endif /* MEM_H */ - - |