To figure out if we're going outside the buffer, use the size of the buffer,
[openssl.git] / crypto / bio / b_print.c
index a9e552f24521974e730a34d1e00695d4d7aa035e..960a049bcafda3d5197730931597ed9cdf34b8bb 100644 (file)
@@ -513,8 +513,8 @@ fmtint(
             (caps ? "0123456789ABCDEF" : "0123456789abcdef")
             [uvalue % (unsigned) base];
         uvalue = (uvalue / (unsigned) base);
-    } while (uvalue && (place < sizeof convert));
-    if (place == sizeof convert)
+    } while (uvalue && (place < (int)sizeof(convert)));
+    if (place == sizeof(convert))
         place--;
     convert[place] = 0;
 
@@ -576,12 +576,12 @@ abs_val(LDOUBLE value)
 }
 
 static LDOUBLE
-pow10(int exp)
+pow10(int in_exp)
 {
     LDOUBLE result = 1;
-    while (exp) {
+    while (in_exp) {
         result *= 10;
-        exp--;
+        in_exp--;
     }
     return result;
 }
@@ -643,7 +643,7 @@ fmtfp(
 
     if (fracpart >= pow10(max)) {
         intpart++;
-        fracpart -= (long)pow10(max);
+        fracpart -= pow10(max);
     }
 
     /* convert integer part */
@@ -652,8 +652,8 @@ fmtfp(
             (caps ? "0123456789ABCDEF"
               : "0123456789abcdef")[intpart % 10];
         intpart = (intpart / 10);
-    } while (intpart && (iplace < sizeof iplace));
-    if (iplace == sizeof iplace)
+    } while (intpart && (iplace < (int)sizeof(iconvert)));
+    if (iplace == sizeof iconvert)
         iplace--;
     iconvert[iplace] = 0;
 
@@ -664,7 +664,7 @@ fmtfp(
               : "0123456789abcdef")[fracpart % 10];
         fracpart = (fracpart / 10);
     } while (fplace < max);
-    if (fplace == sizeof fplace)
+    if (fplace == sizeof fconvert)
         fplace--;
     fconvert[fplace] = 0;
 
@@ -836,5 +836,5 @@ int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args)
                 * had the buffer been large enough.) */
                return -1;
        else
-               return (retlen <= INT_MAX) ? retlen : -1;
+               return (retlen <= INT_MAX) ? (int)retlen : -1;
        }