fixed several coverity reported bugs.
authorNikos Mavrogiannopoulos <nmav@redhat.com>
Tue, 15 Apr 2014 10:12:06 +0000 (12:12 +0200)
committerNikos Mavrogiannopoulos <nmav@redhat.com>
Tue, 15 Apr 2014 10:12:06 +0000 (12:12 +0200)
lib/coding.c
lib/parser_aux.c

index ef2f96f..70cd14f 100644 (file)
@@ -474,6 +474,8 @@ _asn1_complete_explicit_tag (asn1_node node, unsigned char *der,
   if (node->type & CONST_TAG)
     {
       p = node->down;
+      if (p == NULL)
+        return ASN1_DER_ERROR;
       /* When there are nested tags we must complete them reverse to
          the order they were created. This is because completing a tag
          modifies all data within it, including the incomplete tags
@@ -708,7 +710,7 @@ _asn1_ordering_set (unsigned char *der, int der_len, asn1_node node)
   struct vet *first, *last, *p_vet, *p2_vet;
   asn1_node p;
   unsigned char class, *temp;
-  unsigned long tag;
+  unsigned long tag, t;
 
   counter = 0;
 
@@ -716,8 +718,8 @@ _asn1_ordering_set (unsigned char *der, int der_len, asn1_node node)
     return;
 
   p = node->down;
-  while ((type_field (p->type) == ASN1_ETYPE_TAG)
-        || (type_field (p->type) == ASN1_ETYPE_SIZE))
+  while (p && ((type_field (p->type) == ASN1_ETYPE_TAG) ||
+        (type_field (p->type) == ASN1_ETYPE_SIZE)))
     p = p->right;
 
   if ((p == NULL) || (p->right == NULL))
@@ -743,7 +745,9 @@ _asn1_ordering_set (unsigned char *der, int der_len, asn1_node node)
          (der + counter, der_len - counter, &class, &len2,
           &tag) != ASN1_SUCCESS)
        return;
-      p_vet->value = (class << 24) | tag;
+
+      t = class << 24;
+      p_vet->value = t | tag;
       counter += len2;
 
       /* extraction and length */
@@ -829,8 +833,8 @@ _asn1_ordering_set_of (unsigned char *der, int der_len, asn1_node node)
     return;
 
   p = node->down;
-  while ((type_field (p->type) == ASN1_ETYPE_TAG)
-        || (type_field (p->type) == ASN1_ETYPE_SIZE))
+  while (p && ((type_field (p->type) == ASN1_ETYPE_TAG) ||
+        (type_field (p->type) == ASN1_ETYPE_SIZE)))
     p = p->right;
   p = p->right;
 
index fccfed5..6690f49 100644 (file)
@@ -131,7 +131,7 @@ asn1_find_node (asn1_node pointer, const char *name)
 
       while (p)
        {
-         if ((p->name) && nhash == p->name_hash && (!strcmp (p->name, n)))
+         if (nhash == p->name_hash && (!strcmp (p->name, n)))
            break;
          else
            p = p->right;
@@ -909,7 +909,7 @@ _asn1_check_identifier (asn1_node node)
   p = node;
   while (p)
     {
-      if (type_field (p->type) == ASN1_ETYPE_IDENTIFIER)
+      if (p->value && type_field (p->type) == ASN1_ETYPE_IDENTIFIER)
        {
          _asn1_str_cpy (name2, sizeof (name2), node->name);
          _asn1_str_cat (name2, sizeof (name2), ".");