In message <[EMAIL PROTECTED]> on Thu, 11 Dec 2003 18:21:22 +0100 (CET), Richard
Levitte - VMS Whacker <[EMAIL PROTECTED]> said:
levitte> I'll produce patches shortly, but first I've got to figure out some
levitte> funnies with the fractional part. The following source:
levitte>
levitte> BIO_printf(myBio, "float: %.5f\n", (float) 21000.123456);
levitte>
levitte> produces this:
levitte>
levitte> 000.12305
levitte>
levitte> (well actually, after I've corrected the integer part bug, it actually
levitte> outputs 21000.12305 :-)).
A few tests show that this has nothing to do with fmtfp. If I print
0.123456, I get more sensible results. However, exactly the same kind
of problem as for the integer part exists in the encoding of the
fractional part:
/* convert fractional part */
do {
fconvert[fplace++] =
(caps ? "0123456789ABCDEF"
: "0123456789abcdef")[fracpart % 10];
fracpart = (fracpart / 10);
} while (fplace < max);
if (fplace == sizeof fplace)
fplace--;
fconvert[fplace] = 0;
However, because of the way this is written, the bug only shows itself
if the requested size of the fractional part is the size of an int,
like this:
BIO_printf(myBio, "float: %.4f\n", (float) 0.123456);
That gave this result:
float: 0.2350
Anyway, the patch to fix this is attached. I'll commit it promptly.
-----
Please consider sponsoring my work on free software.
See http://www.free.lp.se/sponsoring.html for details.
You don't have to be rich, a $10 donation is appreciated!
--
Richard Levitte \ Tunnlandsv�gen 3 \ [EMAIL PROTECTED]
[EMAIL PROTECTED] \ S-168 36 BROMMA \ T: +46-8-26 52 47
\ SWEDEN \ or +46-708-26 53 44
Procurator Odiosus Ex Infernis -- [EMAIL PROTECTED]
Member of the OpenSSL development team: http://www.openssl.org/
Unsolicited commercial email is subject to an archival fee of $400.
See <http://www.stacken.kth.se/~levitte/mail/> for more info.
Index: crypto/bio/b_print.c
===================================================================
RCS file: /e/openssl/cvs/openssl/crypto/bio/b_print.c,v
retrieving revision 1.34
diff -u -r1.34 b_print.c
--- crypto/bio/b_print.c 4 Nov 2003 00:51:31 -0000 1.34
+++ crypto/bio/b_print.c 11 Dec 2003 17:47:58 -0000
@@ -652,8 +652,8 @@
(caps ? "0123456789ABCDEF"
: "0123456789abcdef")[intpart % 10];
intpart = (intpart / 10);
- } while (intpart && (iplace < (int)sizeof(iplace)));
- if (iplace == sizeof iplace)
+ } while (intpart && (iplace < (int)sizeof(iconvert)));
+ if (iplace == sizeof iconvert)
iplace--;
iconvert[iplace] = 0;
@@ -664,7 +664,7 @@
: "0123456789abcdef")[fracpart % 10];
fracpart = (fracpart / 10);
} while (fplace < max);
- if (fplace == sizeof fplace)
+ if (fplace == sizeof fconvert)
fplace--;
fconvert[fplace] = 0;