summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2014-05-17 00:03:58 +0200
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2014-05-17 00:03:58 +0200
commitf245088c5bd6c7e9bea18e5601ee24d431531558 (patch)
treea0098c0daff56e973080ac381e6b952d9c110c1f /lib
parentf93acf7f0a3f19692c71fc9022981b6f64ffdbc1 (diff)
downloadlibtasn1-f245088c5bd6c7e9bea18e5601ee24d431531558.tar.gz
libtasn1-f245088c5bd6c7e9bea18e5601ee24d431531558.tar.bz2
libtasn1-f245088c5bd6c7e9bea18e5601ee24d431531558.zip
Allow for zero strings.
Diffstat (limited to 'lib')
-rw-r--r--lib/decoding.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/decoding.c b/lib/decoding.c
index 894be79..1151afe 100644
--- a/lib/decoding.c
+++ b/lib/decoding.c
@@ -262,7 +262,10 @@ asn1_get_octet_der (const unsigned char *der, int der_len,
*ret_len = *str_len + len_len;
if (str_size >= *str_len)
- memcpy (str, der + len_len, *str_len);
+ {
+ if (*str_len > 0)
+ memcpy (str, der + len_len, *str_len);
+ }
else
{
return ASN1_MEM_ERROR;
@@ -381,12 +384,15 @@ asn1_get_bit_der (const unsigned char *der, int der_len,
*ret_len = len_byte + len_len + 1;
*bit_len = len_byte * 8 - der[len_len];
-
- if (*bit_len <= 0)
+
+ if (*bit_len < 0)
return ASN1_DER_ERROR;
if (str_size >= len_byte)
- memcpy (str, der + len_len + 1, len_byte);
+ {
+ if (len_byte > 0)
+ memcpy (str, der + len_len + 1, len_byte);
+ }
else
{
return ASN1_MEM_ERROR;