summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/minitasn1/parser_aux.c4
-rw-r--r--lib/minitasn1/parser_aux.h5
2 files changed, 5 insertions, 4 deletions
diff --git a/lib/minitasn1/parser_aux.c b/lib/minitasn1/parser_aux.c
index d3e9009d77..da9a388fe3 100644
--- a/lib/minitasn1/parser_aux.c
+++ b/lib/minitasn1/parser_aux.c
@@ -543,7 +543,7 @@ _asn1_delete_list_and_nodes (void)
char *
-_asn1_ltostr (long v, char *str)
+_asn1_ltostr (long v, char str[LTOSTR_MAX_SIZE])
{
long d, r;
char temp[LTOSTR_MAX_SIZE];
@@ -567,7 +567,7 @@ _asn1_ltostr (long v, char *str)
count++;
v = d;
}
- while (v);
+ while (v && ((start+count) < LTOSTR_MAX_SIZE-1));
for (k = 0; k < count; k++)
str[k + start] = temp[start + count - k - 1];
diff --git a/lib/minitasn1/parser_aux.h b/lib/minitasn1/parser_aux.h
index 55d9061917..437f1c863f 100644
--- a/lib/minitasn1/parser_aux.h
+++ b/lib/minitasn1/parser_aux.h
@@ -52,8 +52,9 @@ void _asn1_delete_list (void);
void _asn1_delete_list_and_nodes (void);
-#define LTOSTR_MAX_SIZE 20
-char *_asn1_ltostr (long v, char *str);
+/* Max 64-bit integer length is 20 chars + 1 for sign + 1 for null termination */
+#define LTOSTR_MAX_SIZE 22
+char *_asn1_ltostr (long v, char str[LTOSTR_MAX_SIZE]);
asn1_node _asn1_find_up (asn1_node node);