diff options
Diffstat (limited to 'lib/parser_aux.c')
-rw-r--r-- | lib/parser_aux.c | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/lib/parser_aux.c b/lib/parser_aux.c index 723d48b..786ea64 100644 --- a/lib/parser_aux.c +++ b/lib/parser_aux.c @@ -84,7 +84,7 @@ _asn1_add_static_node (unsigned int type) * @name: null terminated string with the element's name to find. * * Searches for an element called @name starting from @pointer. The - * name is composed by differents identifiers separated by dots. When + * name is composed by different identifiers separated by dots. When * *@pointer has a name, the first identifier must be the name of * *@pointer, otherwise it must be the name of one child of *@pointer. * @@ -555,31 +555,35 @@ _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; + uint64_t d, r; char temp[LTOSTR_MAX_SIZE]; int count, k, start; + uint64_t val; if (v < 0) { str[0] = '-'; start = 1; - v = -v; + val = -((uint64_t)v); } else - start = 0; + { + val = v; + start = 0; + } count = 0; do { - d = v / 10; - r = v - d * 10; + d = val / 10; + r = val - d * 10; temp[start + count] = '0' + (char) r; count++; - v = d; + val = d; } - while (v && ((start+count) < LTOSTR_MAX_SIZE-1)); + while (val && ((start+count) < LTOSTR_MAX_SIZE-1)); for (k = 0; k < count; k++) str[k + start] = temp[start + count - k - 1]; @@ -643,7 +647,7 @@ _asn1_change_integer_value (asn1_node node) p = NULL; break; } - if (p->right) + if (p && p->right) { p = p->right; break; @@ -759,7 +763,7 @@ _asn1_expand_object_id (asn1_node node) if (move == RIGHT) { - if (p->right) + if (p && p->right) p = p->right; else move = UP; @@ -834,7 +838,7 @@ _asn1_expand_object_id (asn1_node node) if (move == RIGHT) { - if (p->right) + if (p && p->right) p = p->right; else move = UP; @@ -904,7 +908,7 @@ _asn1_type_set_config (asn1_node node) if (move == RIGHT) { - if (p->right) + if (p && p->right) p = p->right; else move = UP; @@ -965,13 +969,14 @@ _asn1_check_identifier (asn1_node node) { _asn1_str_cpy (name2, sizeof (name2), node->name); if (p2->value) - { - _asn1_str_cat (name2, sizeof (name2), "."); - _asn1_str_cat (name2, sizeof (name2), (char *) p2->value); - _asn1_str_cpy (_asn1_identifierMissing, sizeof(_asn1_identifierMissing), (char*)p2->value); - } + { + _asn1_str_cat (name2, sizeof (name2), "."); + _asn1_str_cat (name2, sizeof (name2), (char *) p2->value); + _asn1_str_cpy (_asn1_identifierMissing, sizeof(_asn1_identifierMissing), (char*)p2->value); + } else _asn1_strcpy (_asn1_identifierMissing, "(null)"); + p2 = asn1_find_node (node, name2); if (!p2 || (type_field (p2->type) != ASN1_ETYPE_OBJECT_ID) || !(p2->type & CONST_ASSIGN)) @@ -992,6 +997,7 @@ _asn1_check_identifier (asn1_node node) _asn1_str_cat (name2, sizeof (name2), "."); _asn1_str_cat (name2, sizeof (name2), (char *) p2->value); _asn1_str_cpy (_asn1_identifierMissing, sizeof(_asn1_identifierMissing), (char*)p2->value); + p2 = asn1_find_node (node, name2); if (!p2 || (type_field (p2->type) != ASN1_ETYPE_OBJECT_ID) || !(p2->type & CONST_ASSIGN)) @@ -1018,7 +1024,7 @@ _asn1_check_identifier (asn1_node node) p = NULL; break; } - if (p->right) + if (p && p->right) { p = p->right; break; @@ -1078,7 +1084,7 @@ _asn1_set_default_tag (asn1_node node) p = NULL; break; } - if (p->right) + if (p && p->right) { p = p->right; break; |