]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
ensure that _gnutls_x509_read_value works as documented.
authorNikos Mavrogiannopoulos <nmav@redhat.com>
Thu, 13 Feb 2014 12:28:20 +0000 (13:28 +0100)
committerNikos Mavrogiannopoulos <nmav@redhat.com>
Thu, 13 Feb 2014 14:11:37 +0000 (15:11 +0100)
lib/x509/common.c

index 3c56ee8daefd74f1649573c61ca74db432a2921b..8bde558708cf911001d023af179f0dee919d4b9a 100644 (file)
@@ -1023,8 +1023,7 @@ _gnutls_x509_read_value(ASN1_TYPE c, const char *root,
        }
 
        if (etype == ASN1_ETYPE_BIT_STRING) {
-               len /= 8;
-               len++;
+               len = (len + 7)/8;
        }
 
        tmp = gnutls_malloc((size_t) len + 1);
@@ -1042,12 +1041,11 @@ _gnutls_x509_read_value(ASN1_TYPE c, const char *root,
        }
 
        if (etype == ASN1_ETYPE_BIT_STRING) {
-               ret->size = len / 8;
-               if (len % 8 > 0)
-                       ret->size++;
+               ret->size = (len+7) / 8;
        } else
                ret->size = (unsigned) len;
 
+       tmp[ret->size] = 0;
        ret->data = tmp;
 
        return 0;