summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2014-04-17 15:36:11 +0200
committerNikos Mavrogiannopoulos <nmav@redhat.com>2014-04-17 15:41:16 +0200
commit40ebbd29daa6ad73f944ce045c415d02b76eaedb (patch)
treea0ba95433775e42360aa0c6fd580d00228c3e10d
parent3239b9c45384005ef55edcce541261096669e686 (diff)
downloadlibtasn1-40ebbd29daa6ad73f944ce045c415d02b76eaedb.tar.gz
libtasn1-40ebbd29daa6ad73f944ce045c415d02b76eaedb.tar.bz2
libtasn1-40ebbd29daa6ad73f944ce045c415d02b76eaedb.zip
simplified asn1_find_structure_from_oid() and asn1_expand_any_defined_by().
-rw-r--r--lib/decoding.c12
-rw-r--r--lib/structure.c10
2 files changed, 9 insertions, 13 deletions
diff --git a/lib/decoding.c b/lib/decoding.c
index e9af339..b6c9f1d 100644
--- a/lib/decoding.c
+++ b/lib/decoding.c
@@ -2509,18 +2509,18 @@ asn1_der_decoding_startEnd (asn1_node element, const void *ider, int len,
int
asn1_expand_any_defined_by (asn1_node definitions, asn1_node * element)
{
- char definitionsName[ASN1_MAX_NAME_SIZE], name[2 * ASN1_MAX_NAME_SIZE + 1],
+ char name[2 * ASN1_MAX_NAME_SIZE + 1],
value[ASN1_MAX_NAME_SIZE];
int retCode = ASN1_SUCCESS, result;
int len, len2, len3;
asn1_node p, p2, p3, aux = NULL;
char errorDescription[ASN1_MAX_ERROR_DESCRIPTION_SIZE];
+ const char *definitionsName;
if ((definitions == NULL) || (*element == NULL))
return ASN1_ELEMENT_NOT_FOUND;
- strcpy (definitionsName, definitions->name);
- strcat (definitionsName, ".");
+ definitionsName = definitions->name;
p = *element;
while (p)
@@ -2595,8 +2595,7 @@ asn1_expand_any_defined_by (asn1_node definitions, asn1_node * element)
if ((type_field (p2->type) == ASN1_ETYPE_OBJECT_ID) &&
(p2->type & CONST_ASSIGN))
{
- strcpy (name, definitionsName);
- strcat (name, p2->name);
+ snprintf(name, sizeof(name), "%s.%s", definitionsName, p2->name);
len = ASN1_MAX_NAME_SIZE;
result =
@@ -2612,8 +2611,7 @@ asn1_expand_any_defined_by (asn1_node definitions, asn1_node * element)
if (p2)
{
- strcpy (name, definitionsName);
- strcat (name, p2->name);
+ snprintf(name, sizeof(name), "%s.%s", definitionsName, p2->name);
result =
asn1_create_element (definitions, name, &aux);
diff --git a/lib/structure.c b/lib/structure.c
index 611ed94..d7df904 100644
--- a/lib/structure.c
+++ b/lib/structure.c
@@ -1087,18 +1087,17 @@ asn1_number_of_elements (asn1_node element, const char *name, int *num)
const char *
asn1_find_structure_from_oid (asn1_node definitions, const char *oidValue)
{
- char definitionsName[ASN1_MAX_NAME_SIZE], name[2 * ASN1_MAX_NAME_SIZE + 1];
+ char name[2 * ASN1_MAX_NAME_SIZE + 1];
char value[ASN1_MAX_NAME_SIZE];
asn1_node p;
int len;
int result;
+ const char *definitionsName;
if ((definitions == NULL) || (oidValue == NULL))
return NULL; /* ASN1_ELEMENT_NOT_FOUND; */
-
- strcpy (definitionsName, definitions->name);
- strcat (definitionsName, ".");
+ definitionsName = definitions->name;
/* search the OBJECT_ID into definitions */
p = definitions->down;
@@ -1107,8 +1106,7 @@ asn1_find_structure_from_oid (asn1_node definitions, const char *oidValue)
if ((type_field (p->type) == ASN1_ETYPE_OBJECT_ID) &&
(p->type & CONST_ASSIGN))
{
- strcpy (name, definitionsName);
- strcat (name, p->name);
+ snprintf(name, sizeof(name), "%s.%s", definitionsName, p->name);
len = ASN1_MAX_NAME_SIZE;
result = asn1_read_value (definitions, name, value, &len);