20857N/A lib/coding.c | 13 +++++++++----
20857N/A 1 files changed, 9 insertions(+), 4 deletions(-)
20857N/A
20857N/Adiff --git a/lib/coding.c b/lib/coding.c
20857N/Aindex 111e063..367dada 100644
20857N/A--- a/lib/coding.c
20857N/A+++ b/lib/coding.c
20857N/A@@ -253,18 +253,23 @@ static asn1_retCode
20857N/A _asn1_objectid_der (unsigned char *str, unsigned char *der, int *der_len)
20857N/A {
20857N/A int len_len, counter, k, first, max_len;
20857N/A- char *temp, *n_end, *n_start;
20857N/A+ char *temp = NULL, *n_end, *n_start;
20857N/A unsigned char bit7;
20857N/A unsigned long val, val1 = 0;
20857N/A+ size_t temp_size = str ? strlen (str) : 0;
20857N/A+
20857N/A+ temp_size += 2;
20857N/A+ if (temp_size < 2)
20857N/A+ return ASN1_MEM_ALLOC_ERROR;
20857N/A
20857N/A max_len = *der_len;
20857N/A
20857N/A- temp = (char *) _asn1_malloc (strlen (str) + 2);
20857N/A+ temp = (char *) _asn1_malloc (temp_size);
20857N/A if (temp == NULL)
20857N/A return ASN1_MEM_ALLOC_ERROR;
20857N/A
20857N/A- strcpy (temp, str);
20857N/A- strcat (temp, ".");
20857N/A+ strncpy (temp, str ? (const char *)str : "", temp_size);
20857N/A+ strncat (temp, ".", 1);
20857N/A
20857N/A counter = 0;
20857N/A n_start = temp;