summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bn/bn_print.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/bn/bn_print.c')
-rw-r--r--src/lib/libcrypto/bn/bn_print.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/lib/libcrypto/bn/bn_print.c b/src/lib/libcrypto/bn/bn_print.c
index 5f46b1826c..0d942603b1 100644
--- a/src/lib/libcrypto/bn/bn_print.c
+++ b/src/lib/libcrypto/bn/bn_print.c
@@ -119,6 +119,7 @@ char *BN_bn2dec(const BIGNUM *a)
119 } 119 }
120 if ((t=BN_dup(a)) == NULL) goto err; 120 if ((t=BN_dup(a)) == NULL) goto err;
121 121
122#define BUF_REMAIN (num+3 - (size_t)(p - buf))
122 p=buf; 123 p=buf;
123 lp=bn_data; 124 lp=bn_data;
124 if (t->neg) *(p++)='-'; 125 if (t->neg) *(p++)='-';
@@ -139,12 +140,12 @@ char *BN_bn2dec(const BIGNUM *a)
139 /* We now have a series of blocks, BN_DEC_NUM chars 140 /* We now have a series of blocks, BN_DEC_NUM chars
140 * in length, where the last one needs truncation. 141 * in length, where the last one needs truncation.
141 * The blocks need to be reversed in order. */ 142 * The blocks need to be reversed in order. */
142 sprintf(p,BN_DEC_FMT1,*lp); 143 BIO_snprintf(p,BUF_REMAIN,BN_DEC_FMT1,*lp);
143 while (*p) p++; 144 while (*p) p++;
144 while (lp != bn_data) 145 while (lp != bn_data)
145 { 146 {
146 lp--; 147 lp--;
147 sprintf(p,BN_DEC_FMT2,*lp); 148 BIO_snprintf(p,BUF_REMAIN,BN_DEC_FMT2,*lp);
148 while (*p) p++; 149 while (*p) p++;
149 } 150 }
150 } 151 }