updates in ETYPE_OK
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Sat, 24 Nov 2012 08:07:41 +0000 (09:07 +0100)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Sat, 24 Nov 2012 08:07:41 +0000 (09:07 +0100)
lib/coding.c
lib/int.h
lib/libtasn1.h

index aa777f3..5c1a58b 100644 (file)
@@ -215,7 +215,6 @@ asn1_encode_simple_der (unsigned int etype, const unsigned char *str, unsigned i
 
   if (ETYPE_OK(etype) == 0)
     return ASN1_VALUE_NOT_VALID;
-    
 
   _asn1_tag_der (ETYPE_CLASS(etype), ETYPE_TAG(etype),
                 der_tag, &tag_len);
index 9400cb8..072e0c6 100644 (file)
--- a/lib/int.h
+++ b/lib/int.h
@@ -89,7 +89,9 @@ typedef struct tag_and_class_st {
 
 #define ETYPE_TAG(etype) (_asn1_tags[etype].tag)
 #define ETYPE_CLASS(etype) (_asn1_tags[etype].class)
-#define ETYPE_OK(etype) ((etype <= _asn1_tags_size)?1:0)
+#define ETYPE_OK(etype) ((etype != ASN1_ETYPE_INVALID && \
+                          etype <= _asn1_tags_size && \
+                          _asn1_tags[etype].desc != NULL)?1:0)
 
 extern unsigned int _asn1_tags_size;
 extern const tag_and_class_st _asn1_tags[];
index 59c3093..403ee80 100644 (file)
@@ -135,6 +135,7 @@ extern "C"
   typedef struct asn1_static_node_st asn1_static_node;
 
 /* List of constants for field type of node_asn  */
+#define ASN1_ETYPE_INVALID        0
 #define ASN1_ETYPE_CONSTANT       1
 #define ASN1_ETYPE_IDENTIFIER     2
 #define ASN1_ETYPE_INTEGER        3