diff options
Diffstat (limited to 'lib/element.c')
-rw-r--r-- | lib/element.c | 56 |
1 files changed, 27 insertions, 29 deletions
diff --git a/lib/element.c b/lib/element.c index a4c61bb..d4c558e 100644 --- a/lib/element.c +++ b/lib/element.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000-2014 Free Software Foundation, Inc. + * Copyright (C) 2000-2022 Free Software Foundation, Inc. * * This file is part of LIBTASN1. * @@ -30,7 +30,7 @@ #include "parser_aux.h" #include <gstr.h> #include "structure.h" - +#include "c-ctype.h" #include "element.h" void @@ -115,7 +115,7 @@ _asn1_convert_integer (const unsigned char *value, unsigned char *value_out, if (value_out != NULL) { for (k2 = k; k2 < SIZEOF_UNSIGNED_LONG_INT; k2++) - value_out[k2 - k] = val[k2]; + value_out[k2 - k] = val[k2]; } #if 0 @@ -142,7 +142,7 @@ int _asn1_append_sequence_set (asn1_node node, struct node_tail_cache_st *pcache) { asn1_node p, p2; - char temp[LTOSTR_MAX_SIZE]; + char temp[LTOSTR_MAX_SIZE + 1]; long n; if (!node || !(node->down)) @@ -160,9 +160,9 @@ _asn1_append_sequence_set (asn1_node node, struct node_tail_cache_st *pcache) if (pcache == NULL || pcache->tail == NULL || pcache->head != node) { while (p->right) - { - p = p->right; - } + { + p = p->right; + } } else { @@ -321,7 +321,8 @@ asn1_write_value (asn1_node node_root, const char *name, type = type_field (node->type); - if ((type == ASN1_ETYPE_SEQUENCE_OF || type == ASN1_ETYPE_SET_OF) && (value == NULL) && (len == 0)) + if ((type == ASN1_ETYPE_SEQUENCE_OF || type == ASN1_ETYPE_SET_OF) + && (value == NULL) && (len == 0)) { p = node->down; while ((type_field (p->type) == ASN1_ETYPE_TAG) @@ -380,7 +381,7 @@ asn1_write_value (asn1_node node_root, const char *name, case ASN1_ETYPE_ENUMERATED: if (len == 0) { - if ((isdigit (value[0])) || (value[0] == '-')) + if ((c_isdigit (value[0])) || (value[0] == '-')) { value_temp = malloc (SIZEOF_UNSIGNED_LONG_INT); if (value_temp == NULL) @@ -453,7 +454,7 @@ asn1_write_value (asn1_node node_root, const char *name, p = node->down; while (type_field (p->type) != ASN1_ETYPE_DEFAULT) p = p->right; - if ((isdigit (p->value[0])) || (p->value[0] == '-')) + if ((c_isdigit (p->value[0])) || (p->value[0] == '-')) { default_temp = malloc (SIZEOF_UNSIGNED_LONG_INT); if (default_temp == NULL) @@ -519,7 +520,7 @@ asn1_write_value (asn1_node node_root, const char *name, break; case ASN1_ETYPE_OBJECT_ID: for (i = 0; i < _asn1_strlen (value); i++) - if ((!isdigit (value[i])) && (value[i] != '.') && (value[i] != '+')) + if ((!c_isdigit (value[i])) && (value[i] != '.') && (value[i] != '+')) return ASN1_VALUE_NOT_VALID; if (node->type & CONST_DEFAULT) { @@ -540,7 +541,7 @@ asn1_write_value (asn1_node node_root, const char *name, if (len < 11) return ASN1_VALUE_NOT_VALID; for (k = 0; k < 10; k++) - if (!isdigit (value[k])) + if (!c_isdigit (value[k])) return ASN1_VALUE_NOT_VALID; switch (len) { @@ -549,7 +550,7 @@ asn1_write_value (asn1_node node_root, const char *name, return ASN1_VALUE_NOT_VALID; break; case 13: - if ((!isdigit (value[10])) || (!isdigit (value[11])) || + if ((!c_isdigit (value[10])) || (!c_isdigit (value[11])) || (value[12] != 'Z')) return ASN1_VALUE_NOT_VALID; break; @@ -557,16 +558,16 @@ asn1_write_value (asn1_node node_root, const char *name, if ((value[10] != '+') && (value[10] != '-')) return ASN1_VALUE_NOT_VALID; for (k = 11; k < 15; k++) - if (!isdigit (value[k])) + if (!c_isdigit (value[k])) return ASN1_VALUE_NOT_VALID; break; case 17: - if ((!isdigit (value[10])) || (!isdigit (value[11]))) + if ((!c_isdigit (value[10])) || (!c_isdigit (value[11]))) return ASN1_VALUE_NOT_VALID; if ((value[12] != '+') && (value[12] != '-')) return ASN1_VALUE_NOT_VALID; for (k = 13; k < 17; k++) - if (!isdigit (value[k])) + if (!c_isdigit (value[k])) return ASN1_VALUE_NOT_VALID; break; default: @@ -757,7 +758,8 @@ asn1_write_value (asn1_node node_root, const char *name, * this function may return %ASN1_SUCCESS even if the provided @len is zero. **/ int -asn1_read_value (asn1_node_const root, const char *name, void *ivalue, int *len) +asn1_read_value (asn1_node_const root, const char *name, void *ivalue, + int *len) { return asn1_read_value_type (root, name, ivalue, len, NULL); } @@ -890,12 +892,12 @@ asn1_read_value_type (asn1_node_const root, const char *name, void *ivalue, p = node->down; while (type_field (p->type) != ASN1_ETYPE_DEFAULT) p = p->right; - if ((isdigit (p->value[0])) || (p->value[0] == '-') + if ((c_isdigit (p->value[0])) || (p->value[0] == '-') || (p->value[0] == '+')) { result = _asn1_convert_integer - (p->value, value, value_size, len); - if (result != ASN1_SUCCESS) + (p->value, value, value_size, len); + if (result != ASN1_SUCCESS) return result; } else @@ -908,8 +910,7 @@ asn1_read_value_type (asn1_node_const root, const char *name, void *ivalue, if (!_asn1_strcmp (p2->name, p->value)) { result = _asn1_convert_integer - (p2->value, value, value_size, - len); + (p2->value, value, value_size, len); if (result != ASN1_SUCCESS) return result; break; @@ -923,9 +924,8 @@ asn1_read_value_type (asn1_node_const root, const char *name, void *ivalue, { len2 = -1; result = asn1_get_octet_der - (node->value, node->value_len, &len2, value, value_size, - len); - if (result != ASN1_SUCCESS) + (node->value, node->value_len, &len2, value, value_size, len); + if (result != ASN1_SUCCESS) return result; } break; @@ -978,16 +978,14 @@ asn1_read_value_type (asn1_node_const root, const char *name, void *ivalue, case ASN1_ETYPE_VISIBLE_STRING: len2 = -1; result = asn1_get_octet_der - (node->value, node->value_len, &len2, value, value_size, - len); + (node->value, node->value_len, &len2, value, value_size, len); if (result != ASN1_SUCCESS) return result; break; case ASN1_ETYPE_BIT_STRING: len2 = -1; result = asn1_get_bit_der - (node->value, node->value_len, &len2, value, value_size, - len); + (node->value, node->value_len, &len2, value, value_size, len); if (result != ASN1_SUCCESS) return result; break; |