Synchronise the VMS build with the Unix one.
[oweals/openssl.git] / crypto / asn1 / a_bitstr.c
index 35fe01d27e31fcbc4e9a10c613a1ce0c1cec42b4..7013a407ad68385d0f82c27ec6d4aed864f5d4ea 100644 (file)
@@ -75,7 +75,7 @@ int i2d_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp)
        len = i2c_ASN1_BIT_STRING(a, NULL);     
        ret=ASN1_object_size(0,len,V_ASN1_BIT_STRING);
        if(pp) {
-               ASN1_put_object(pp,0,ret,V_ASN1_BIT_STRING,V_ASN1_UNIVERSAL);
+               ASN1_put_object(pp,0,len,V_ASN1_BIT_STRING,V_ASN1_UNIVERSAL);
                i2c_ASN1_BIT_STRING(a, pp);     
        }
        return ret;
@@ -236,10 +236,10 @@ int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value)
                else
                        c=(unsigned char *)OPENSSL_realloc(a->data,w+1);
                if (c == NULL) return(0);
+               if (w+1-a->length > 0) memset(c+a->length, 0, w+1-a->length);
                a->data=c;
                a->length=w+1;
-               c[w]=0;
-               }
+       }
        a->data[w]=((a->data[w])&iv)|v;
        while ((a->length > 0) && (a->data[a->length-1] == 0))
                a->length--;