On Sun, 03 Feb 2002, Richard Levitte - VMS Whacker wrote:
> From: Richard Levitte - VMS Whacker <[EMAIL PROTECTED]>
>
> levitte> Well found bug, but incorrect correction, because your patch will
> levitte> still not clear a set bit (as one would expect if you gave the value 0
> levitte> for a bit number that was early given the value 1).
>
> While I looked at this, I noticed this function is quite inefficient
> when trying to figure out if more memory is needed. Not the
> allocation bit itself, but rather that it will count down length when
> the last bytes are 0, and thereby lose all info on how much memory it
> has really allocated, which means that there's a potential unneeded
> OPENSSL_realloc() happening in the next few calls if the next n is
> larger than the current length*8.
Saw that too. I realized my mistake btw and here is a updated
patch. Is there any reason for doing
a->data[w]=((a->data[w])&iv)|v
instead of
a->data[w]=(a->data[w])|v
/Sam
--- openssl-0.9.6c/crypto/asn1/a_bitstr.c Sat Aug 5 20:35:03 2000
+++ openssl-0.9.6c-patched/crypto/asn1/a_bitstr.c Sun Feb 3 15:05:34 2002
@@ -240,7 +240,12 @@
a->data=c;
a->length=w+1;
}
- a->data[w]=((a->data[w])&iv)|v;
+
+ if(value)
+ a->data[w]=((a->data[w])&iv)|v;
+ else
+ a->data[w]=(a->data[w])&iv;
+
while ((a->length > 0) && (a->data[a->length-1] == 0))
a->length--;
return(1);