Avoid PKCS #1 v1.5 signature attack discovered by Daniel Bleichenbacher
[openssl.git] / crypto / bio / b_print.c
index de74ec6df9d49d6210311d70828a2b70f77c7cf1..b2d6f26f2e1f223a0a709b30862ab4ec1d3a481a 100644 (file)
 #define LDOUBLE double
 #endif
 
-#if HAVE_LONG_LONG
+#ifdef HAVE_LONG_LONG
 # if defined(OPENSSL_SYS_WIN32) && !defined(__GNUC__)
 # define LLONG _int64
 # else
@@ -482,7 +482,7 @@ fmtint(
     int flags)
 {
     int signvalue = 0;
-    char *prefix = "";
+    const char *prefix = "";
     unsigned LLONG uvalue;
     char convert[DECIMAL_SIZE(value)+3];
     int place = 0;
@@ -576,7 +576,7 @@ abs_val(LDOUBLE value)
 }
 
 static LDOUBLE
-pow10(int in_exp)
+pow_10(int in_exp)
 {
     LDOUBLE result = 1;
     while (in_exp) {
@@ -619,6 +619,7 @@ fmtfp(
     int caps = 0;
     long intpart;
     long fracpart;
+    long max10;
 
     if (max < 0)
         max = 6;
@@ -639,11 +640,12 @@ fmtfp(
 
     /* we "cheat" by converting the fractional part to integer by
        multiplying by a factor of 10 */
-    fracpart = roundv((pow10(max)) * (ufvalue - intpart));
+    max10 = roundv(pow_10(max));
+    fracpart = roundv(pow_10(max) * (ufvalue - intpart));
 
-    if (fracpart >= pow10(max)) {
+    if (fracpart >= max10) {
         intpart++;
-        fracpart -= pow10(max);
+        fracpart -= max10;
     }
 
     /* convert integer part */
@@ -652,8 +654,8 @@ fmtfp(
             (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 +666,7 @@ fmtfp(
               : "0123456789abcdef")[fracpart % 10];
         fracpart = (fracpart / 10);
     } while (fplace < max);
-    if (fplace == sizeof fplace)
+    if (fplace == sizeof fconvert)
         fplace--;
     fconvert[fplace] = 0;