diff options
Diffstat (limited to 'src/lib/libcrypto/bio/b_print.c')
-rw-r--r-- | src/lib/libcrypto/bio/b_print.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/lib/libcrypto/bio/b_print.c b/src/lib/libcrypto/bio/b_print.c index 3a87b0ec0b..f2bd91d5a0 100644 --- a/src/lib/libcrypto/bio/b_print.c +++ b/src/lib/libcrypto/bio/b_print.c | |||
@@ -79,7 +79,7 @@ | |||
79 | #include <openssl/bn.h> /* To get BN_LLONG properly defined */ | 79 | #include <openssl/bn.h> /* To get BN_LLONG properly defined */ |
80 | #include <openssl/bio.h> | 80 | #include <openssl/bio.h> |
81 | 81 | ||
82 | #if defined(BN_LLONG) || defined(SIXTY_FOUR_BIT) | 82 | #ifdef BN_LLONG |
83 | # ifndef HAVE_LONG_LONG | 83 | # ifndef HAVE_LONG_LONG |
84 | # define HAVE_LONG_LONG 1 | 84 | # define HAVE_LONG_LONG 1 |
85 | # endif | 85 | # endif |
@@ -117,7 +117,7 @@ | |||
117 | 117 | ||
118 | #if HAVE_LONG_LONG | 118 | #if HAVE_LONG_LONG |
119 | # if defined(OPENSSL_SYS_WIN32) && !defined(__GNUC__) | 119 | # if defined(OPENSSL_SYS_WIN32) && !defined(__GNUC__) |
120 | # define LLONG __int64 | 120 | # define LLONG _int64 |
121 | # else | 121 | # else |
122 | # define LLONG long long | 122 | # define LLONG long long |
123 | # endif | 123 | # endif |
@@ -482,7 +482,7 @@ fmtint( | |||
482 | int flags) | 482 | int flags) |
483 | { | 483 | { |
484 | int signvalue = 0; | 484 | int signvalue = 0; |
485 | const char *prefix = ""; | 485 | char *prefix = ""; |
486 | unsigned LLONG uvalue; | 486 | unsigned LLONG uvalue; |
487 | char convert[DECIMAL_SIZE(value)+3]; | 487 | char convert[DECIMAL_SIZE(value)+3]; |
488 | int place = 0; | 488 | int place = 0; |
@@ -513,8 +513,8 @@ fmtint( | |||
513 | (caps ? "0123456789ABCDEF" : "0123456789abcdef") | 513 | (caps ? "0123456789ABCDEF" : "0123456789abcdef") |
514 | [uvalue % (unsigned) base]; | 514 | [uvalue % (unsigned) base]; |
515 | uvalue = (uvalue / (unsigned) base); | 515 | uvalue = (uvalue / (unsigned) base); |
516 | } while (uvalue && (place < (int)sizeof(convert))); | 516 | } while (uvalue && (place < sizeof convert)); |
517 | if (place == sizeof(convert)) | 517 | if (place == sizeof convert) |
518 | place--; | 518 | place--; |
519 | convert[place] = 0; | 519 | convert[place] = 0; |
520 | 520 | ||
@@ -619,7 +619,6 @@ fmtfp( | |||
619 | int caps = 0; | 619 | int caps = 0; |
620 | long intpart; | 620 | long intpart; |
621 | long fracpart; | 621 | long fracpart; |
622 | long max10; | ||
623 | 622 | ||
624 | if (max < 0) | 623 | if (max < 0) |
625 | max = 6; | 624 | max = 6; |
@@ -640,12 +639,11 @@ fmtfp( | |||
640 | 639 | ||
641 | /* we "cheat" by converting the fractional part to integer by | 640 | /* we "cheat" by converting the fractional part to integer by |
642 | multiplying by a factor of 10 */ | 641 | multiplying by a factor of 10 */ |
643 | max10 = roundv(pow_10(max)); | 642 | fracpart = roundv((pow_10(max)) * (ufvalue - intpart)); |
644 | fracpart = roundv(pow_10(max) * (ufvalue - intpart)); | ||
645 | 643 | ||
646 | if (fracpart >= max10) { | 644 | if (fracpart >= (long)pow_10(max)) { |
647 | intpart++; | 645 | intpart++; |
648 | fracpart -= max10; | 646 | fracpart -= (long)pow_10(max); |
649 | } | 647 | } |
650 | 648 | ||
651 | /* convert integer part */ | 649 | /* convert integer part */ |
@@ -654,7 +652,7 @@ fmtfp( | |||
654 | (caps ? "0123456789ABCDEF" | 652 | (caps ? "0123456789ABCDEF" |
655 | : "0123456789abcdef")[intpart % 10]; | 653 | : "0123456789abcdef")[intpart % 10]; |
656 | intpart = (intpart / 10); | 654 | intpart = (intpart / 10); |
657 | } while (intpart && (iplace < (int)sizeof(iconvert))); | 655 | } while (intpart && (iplace < sizeof iconvert)); |
658 | if (iplace == sizeof iconvert) | 656 | if (iplace == sizeof iconvert) |
659 | iplace--; | 657 | iplace--; |
660 | iconvert[iplace] = 0; | 658 | iconvert[iplace] = 0; |
@@ -808,6 +806,7 @@ int BIO_vprintf (BIO *bio, const char *format, va_list args) | |||
808 | } | 806 | } |
809 | 807 | ||
810 | /* As snprintf is not available everywhere, we provide our own implementation. | 808 | /* As snprintf is not available everywhere, we provide our own implementation. |
809 | * In case of overflow or error, this returns -1. | ||
811 | * This function has nothing to do with BIOs, but it's closely related | 810 | * This function has nothing to do with BIOs, but it's closely related |
812 | * to BIO_printf, and we need *some* name prefix ... | 811 | * to BIO_printf, and we need *some* name prefix ... |
813 | * (XXX the function should be renamed, but to what?) */ | 812 | * (XXX the function should be renamed, but to what?) */ |
@@ -832,10 +831,10 @@ int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args) | |||
832 | _dopr(&buf, NULL, &n, &retlen, &truncated, format, args); | 831 | _dopr(&buf, NULL, &n, &retlen, &truncated, format, args); |
833 | 832 | ||
834 | if (truncated) | 833 | if (truncated) |
835 | /* In case of truncation, return -1 like traditional snprintf. | 834 | /* In case of truncation, return -1 unlike traditional snprintf. |
836 | * (Current drafts for ISO/IEC 9899 say snprintf should return | 835 | * (Current drafts for ISO/IEC 9899 say snprintf should return |
837 | * the number of characters that would have been written, | 836 | * the number of characters that would have been written, |
838 | * had the buffer been large enough.) */ | 837 | * had the buffer been large enough, as it did historically.) */ |
839 | return -1; | 838 | return -1; |
840 | else | 839 | else |
841 | return (retlen <= INT_MAX) ? (int)retlen : -1; | 840 | return (retlen <= INT_MAX) ? (int)retlen : -1; |