projects
/
oweals
/
openssl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add function CMS_RecipientInfo_encrypt
[oweals/openssl.git]
/
crypto
/
bio
/
b_print.c
diff --git
a/crypto/bio/b_print.c
b/crypto/bio/b_print.c
index 7c3c9bdf69f7b08511467c01d0911c8448f027da..143a7cfefa37e201bc5bd11d53fac7cd23dff17f 100644
(file)
--- a/
crypto/bio/b_print.c
+++ b/
crypto/bio/b_print.c
@@
-56,6
+56,13
@@
* [including the GNU Public Licence.]
*/
* [including the GNU Public Licence.]
*/
+/* disable assert() unless BIO_DEBUG has been defined */
+#ifndef BIO_DEBUG
+# ifndef NDEBUG
+# define NDEBUG
+# endif
+#endif
+
/*
* Stolen from tjh's ssl/ssl_trc.c stuff.
*/
/*
* Stolen from tjh's ssl/ssl_trc.c stuff.
*/
@@
-72,7
+79,7
@@
#include <openssl/bn.h> /* To get BN_LLONG properly defined */
#include <openssl/bio.h>
#include <openssl/bn.h> /* To get BN_LLONG properly defined */
#include <openssl/bio.h>
-#if
def BN_LLONG
+#if
defined(BN_LLONG) || defined(SIXTY_FOUR_BIT)
# ifndef HAVE_LONG_LONG
# define HAVE_LONG_LONG 1
# endif
# ifndef HAVE_LONG_LONG
# define HAVE_LONG_LONG 1
# endif
@@
-102,15
+109,15
@@
* o ... (for OpenSSL)
*/
* o ... (for OpenSSL)
*/
-#if HAVE_LONG_DOUBLE
+#if
def
HAVE_LONG_DOUBLE
#define LDOUBLE long double
#else
#define LDOUBLE double
#endif
#define LDOUBLE long double
#else
#define LDOUBLE double
#endif
-#if HAVE_LONG_LONG
-# if defined(
OPENSSL_SYS
_WIN32) && !defined(__GNUC__)
-# define LLONG _int64
+#if
def
HAVE_LONG_LONG
+# if defined(_WIN32) && !defined(__GNUC__)
+# define LLONG _
_
int64
# else
# define LLONG long long
# endif
# else
# define LLONG long long
# endif
@@
-371,7
+378,7
@@
_dopr(
case 'p':
value = (long)va_arg(args, void *);
fmtint(sbuffer, buffer, &currlen, maxlen,
case 'p':
value = (long)va_arg(args, void *);
fmtint(sbuffer, buffer, &currlen, maxlen,
- value, 16, min, max, flags);
+ value, 16, min, max, flags
|DP_F_NUM
);
break;
case 'n': /* XXX */
if (cflags == DP_C_SHORT) {
break;
case 'n': /* XXX */
if (cflags == DP_C_SHORT) {
@@
-475,8
+482,9
@@
fmtint(
int flags)
{
int signvalue = 0;
int flags)
{
int signvalue = 0;
+ const char *prefix = "";
unsigned LLONG uvalue;
unsigned LLONG uvalue;
- char convert[
20
];
+ char convert[
DECIMAL_SIZE(value)+3
];
int place = 0;
int spadlen = 0;
int zpadlen = 0;
int place = 0;
int spadlen = 0;
int zpadlen = 0;
@@
-494,6
+502,10
@@
fmtint(
else if (flags & DP_F_SPACE)
signvalue = ' ';
}
else if (flags & DP_F_SPACE)
signvalue = ' ';
}
+ if (flags & DP_F_NUM) {
+ if (base == 8) prefix = "0";
+ if (base == 16) prefix = "0x";
+ }
if (flags & DP_F_UP)
caps = 1;
do {
if (flags & DP_F_UP)
caps = 1;
do {
@@
-501,13
+513,13
@@
fmtint(
(caps ? "0123456789ABCDEF" : "0123456789abcdef")
[uvalue % (unsigned) base];
uvalue = (uvalue / (unsigned) base);
(caps ? "0123456789ABCDEF" : "0123456789abcdef")
[uvalue % (unsigned) base];
uvalue = (uvalue / (unsigned) base);
- } while (uvalue && (place <
20
));
- if (place ==
20
)
+ } while (uvalue && (place <
(int)sizeof(convert)
));
+ if (place ==
sizeof(convert)
)
place--;
convert[place] = 0;
zpadlen = max - place;
place--;
convert[place] = 0;
zpadlen = max - place;
- spadlen = min - OSSL_MAX(max, place) - (signvalue ? 1 : 0);
+ spadlen = min - OSSL_MAX(max, place) - (signvalue ? 1 : 0)
- strlen(prefix)
;
if (zpadlen < 0)
zpadlen = 0;
if (spadlen < 0)
if (zpadlen < 0)
zpadlen = 0;
if (spadlen < 0)
@@
-529,6
+541,12
@@
fmtint(
if (signvalue)
doapr_outch(sbuffer, buffer, currlen, maxlen, signvalue);
if (signvalue)
doapr_outch(sbuffer, buffer, currlen, maxlen, signvalue);
+ /* prefix */
+ while (*prefix) {
+ doapr_outch(sbuffer, buffer, currlen, maxlen, *prefix);
+ prefix++;
+ }
+
/* zeros */
if (zpadlen > 0) {
while (zpadlen > 0) {
/* zeros */
if (zpadlen > 0) {
while (zpadlen > 0) {
@@
-558,12
+576,12
@@
abs_val(LDOUBLE value)
}
static LDOUBLE
}
static LDOUBLE
-pow
10(int
exp)
+pow
_10(int in_
exp)
{
LDOUBLE result = 1;
{
LDOUBLE result = 1;
- while (exp) {
+ while (
in_
exp) {
result *= 10;
result *= 10;
- exp--;
+
in_
exp--;
}
return result;
}
}
return result;
}
@@
-601,6
+619,7
@@
fmtfp(
int caps = 0;
long intpart;
long fracpart;
int caps = 0;
long intpart;
long fracpart;
+ long max10;
if (max < 0)
max = 6;
if (max < 0)
max = 6;
@@
-621,11
+640,12
@@
fmtfp(
/* we "cheat" by converting the fractional part to integer by
multiplying by a factor of 10 */
/* 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++;
intpart++;
- fracpart -=
(long)pow10(max)
;
+ fracpart -=
max10
;
}
/* convert integer part */
}
/* convert integer part */
@@
-634,8
+654,8
@@
fmtfp(
(caps ? "0123456789ABCDEF"
: "0123456789abcdef")[intpart % 10];
intpart = (intpart / 10);
(caps ? "0123456789ABCDEF"
: "0123456789abcdef")[intpart % 10];
intpart = (intpart / 10);
- } while (intpart && (iplace <
20
));
- if (iplace ==
20
)
+ } while (intpart && (iplace <
(int)sizeof(iconvert)
));
+ if (iplace ==
sizeof iconvert
)
iplace--;
iconvert[iplace] = 0;
iplace--;
iconvert[iplace] = 0;
@@
-646,7
+666,7
@@
fmtfp(
: "0123456789abcdef")[fracpart % 10];
fracpart = (fracpart / 10);
} while (fplace < max);
: "0123456789abcdef")[fracpart % 10];
fracpart = (fracpart / 10);
} while (fplace < max);
- if (fplace ==
20
)
+ if (fplace ==
sizeof fconvert
)
fplace--;
fconvert[fplace] = 0;
fplace--;
fconvert[fplace] = 0;
@@
-685,7
+705,7
@@
fmtfp(
* Decimal point. This should probably use locale to find the correct
* char to print out.
*/
* Decimal point. This should probably use locale to find the correct
* char to print out.
*/
- if (max > 0) {
+ if (max > 0
|| (flags & DP_F_NUM)
) {
doapr_outch(sbuffer, buffer, currlen, maxlen, '.');
while (fplace > 0)
doapr_outch(sbuffer, buffer, currlen, maxlen, '.');
while (fplace > 0)
@@
-818,5
+838,5
@@
int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args)
* had the buffer been large enough.) */
return -1;
else
* had the buffer been large enough.) */
return -1;
else
- return (retlen <= INT_MAX) ? retlen : -1;
+ return (retlen <= INT_MAX) ?
(int)
retlen : -1;
}
}