b3c9e1
diff -up libtasn1-4.16.0/lib/coding.c.coverity libtasn1-4.16.0/lib/coding.c
b3c9e1
--- libtasn1-4.16.0/lib/coding.c.coverity	2020-02-01 23:22:04.000000000 +0100
b3c9e1
+++ libtasn1-4.16.0/lib/coding.c	2021-04-13 17:34:34.101819976 +0200
b3c9e1
@@ -1103,7 +1103,10 @@ asn1_der_coding (asn1_node_const element
b3c9e1
   max_len = *len;
b3c9e1
 
b3c9e1
   if (der == NULL && max_len > 0)
b3c9e1
-    return ASN1_VALUE_NOT_VALID;
b3c9e1
+    {
b3c9e1
+      err = ASN1_VALUE_NOT_VALID;
b3c9e1
+      goto error;
b3c9e1
+    }
b3c9e1
 
b3c9e1
   counter = 0;
b3c9e1
   move = DOWN;
b3c9e1
diff -up libtasn1-4.16.0/lib/element.c.coverity libtasn1-4.16.0/lib/element.c
b3c9e1
--- libtasn1-4.16.0/lib/element.c.coverity	2020-01-03 23:20:17.000000000 +0100
b3c9e1
+++ libtasn1-4.16.0/lib/element.c	2021-04-13 18:05:21.054820798 +0200
b3c9e1
@@ -142,7 +142,7 @@ int
b3c9e1
 _asn1_append_sequence_set (asn1_node node, struct node_tail_cache_st *pcache)
b3c9e1
 {
b3c9e1
   asn1_node p, p2;
b3c9e1
-  char temp[LTOSTR_MAX_SIZE];
b3c9e1
+  char temp[LTOSTR_MAX_SIZE+1];
b3c9e1
   long n;
b3c9e1
 
b3c9e1
   if (!node || !(node->down))
b3c9e1
@@ -183,7 +183,12 @@ _asn1_append_sequence_set (asn1_node nod
b3c9e1
       n = strtol (p->name + 1, NULL, 0);
b3c9e1
       n++;
b3c9e1
       temp[0] = '?';
b3c9e1
+      if (n < 0)
b3c9e1
+	return ASN1_GENERIC_ERROR;
b3c9e1
+      /* assuming non-negative n, we have enough space in buffer */
b3c9e1
       _asn1_ltostr (n, temp + 1);
b3c9e1
+      if (strlen(temp) >= LTOSTR_MAX_SIZE)
b3c9e1
+	return ASN1_GENERIC_ERROR;
b3c9e1
     }
b3c9e1
   _asn1_set_name (p2, temp);
b3c9e1
   /*  p2->type |= CONST_OPTION; */
b3c9e1
diff -up libtasn1-4.16.0/lib/int.h.coverity libtasn1-4.16.0/lib/int.h
b3c9e1
--- libtasn1-4.16.0/lib/int.h.coverity	2020-01-03 23:20:17.000000000 +0100
b3c9e1
+++ libtasn1-4.16.0/lib/int.h	2021-04-13 17:34:34.101819976 +0200
b3c9e1
@@ -213,6 +213,7 @@ void *_asn1_realloc(void *ptr, size_t si
b3c9e1
   ret = realloc(ptr, size);
b3c9e1
   if (ret == NULL)
b3c9e1
     {
b3c9e1
+      /* cppcheck-suppress doubleFree */
b3c9e1
       free(ptr);
b3c9e1
     }
b3c9e1
   return ret;
b3c9e1
diff -up libtasn1-4.16.0/src/asn1Coding.c.coverity libtasn1-4.16.0/src/asn1Coding.c
b3c9e1
--- libtasn1-4.16.0/src/asn1Coding.c.coverity	2019-07-19 19:55:08.000000000 +0200
b3c9e1
+++ libtasn1-4.16.0/src/asn1Coding.c	2021-04-13 17:34:34.102819982 +0200
b3c9e1
@@ -72,13 +72,13 @@ readAssignment (FILE * file, char *varNa
b3c9e1
 
b3c9e1
   int ret;
b3c9e1
 
b3c9e1
-  ret = fscanf (file, "%s", varName);
b3c9e1
+  ret = fscanf (file, "%1023s", varName);
b3c9e1
   if (ret == EOF)
b3c9e1
     return ASSIGNMENT_EOF;
b3c9e1
   if (!strcmp (varName, "''"))
b3c9e1
     varName[0] = 0;
b3c9e1
 
b3c9e1
-  ret = fscanf (file, "%s", value);
b3c9e1
+  ret = fscanf (file, "%1023s", value);
b3c9e1
   if (ret == EOF)
b3c9e1
     return ASSIGNMENT_ERROR;
b3c9e1