summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorderaadt <>2015-09-13 15:59:29 +0000
committerderaadt <>2015-09-13 15:59:29 +0000
commitc837375615c4fb3a4d293ba2da1f5799a33105f5 (patch)
tree1dd1559f27a0e8424f7edc2f85a01014dba518ba
parenta09b907e88e54dc0476432cae192084e3d0a1312 (diff)
downloadopenbsd-c837375615c4fb3a4d293ba2da1f5799a33105f5.tar.gz
openbsd-c837375615c4fb3a4d293ba2da1f5799a33105f5.tar.bz2
openbsd-c837375615c4fb3a4d293ba2da1f5799a33105f5.zip
BN does support negative-zero -- BN_print() sets the standard here.
BN_bn2hex() had a 1-byte overflow when creating "-0\0". Reported to me a while back by unknown person -- did not have enough experience to push this through then. advice from jsing, ok miod
-rw-r--r--src/lib/libcrypto/bn/bn_print.c6
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_print.c6
2 files changed, 6 insertions, 6 deletions
diff --git a/src/lib/libcrypto/bn/bn_print.c b/src/lib/libcrypto/bn/bn_print.c
index 4920705a5b..6b9f82caaf 100644
--- a/src/lib/libcrypto/bn/bn_print.c
+++ b/src/lib/libcrypto/bn/bn_print.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_print.c,v 1.23 2014/07/12 16:03:36 miod Exp $ */ 1/* $OpenBSD: bn_print.c,v 1.24 2015/09/13 15:59:29 deraadt Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -77,13 +77,13 @@ BN_bn2hex(const BIGNUM *a)
77 char *buf; 77 char *buf;
78 char *p; 78 char *p;
79 79
80 buf = malloc(a->top * BN_BYTES * 2 + 2); 80 buf = malloc(BN_is_negative(a) + a->top * BN_BYTES * 2 + 2);
81 if (buf == NULL) { 81 if (buf == NULL) {
82 BNerr(BN_F_BN_BN2HEX, ERR_R_MALLOC_FAILURE); 82 BNerr(BN_F_BN_BN2HEX, ERR_R_MALLOC_FAILURE);
83 goto err; 83 goto err;
84 } 84 }
85 p = buf; 85 p = buf;
86 if (a->neg) 86 if (BN_is_negative(a))
87 *(p++) = '-'; 87 *(p++) = '-';
88 if (BN_is_zero(a)) 88 if (BN_is_zero(a))
89 *(p++) = '0'; 89 *(p++) = '0';
diff --git a/src/lib/libssl/src/crypto/bn/bn_print.c b/src/lib/libssl/src/crypto/bn/bn_print.c
index 4920705a5b..6b9f82caaf 100644
--- a/src/lib/libssl/src/crypto/bn/bn_print.c
+++ b/src/lib/libssl/src/crypto/bn/bn_print.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_print.c,v 1.23 2014/07/12 16:03:36 miod Exp $ */ 1/* $OpenBSD: bn_print.c,v 1.24 2015/09/13 15:59:29 deraadt Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -77,13 +77,13 @@ BN_bn2hex(const BIGNUM *a)
77 char *buf; 77 char *buf;
78 char *p; 78 char *p;
79 79
80 buf = malloc(a->top * BN_BYTES * 2 + 2); 80 buf = malloc(BN_is_negative(a) + a->top * BN_BYTES * 2 + 2);
81 if (buf == NULL) { 81 if (buf == NULL) {
82 BNerr(BN_F_BN_BN2HEX, ERR_R_MALLOC_FAILURE); 82 BNerr(BN_F_BN_BN2HEX, ERR_R_MALLOC_FAILURE);
83 goto err; 83 goto err;
84 } 84 }
85 p = buf; 85 p = buf;
86 if (a->neg) 86 if (BN_is_negative(a))
87 *(p++) = '-'; 87 *(p++) = '-';
88 if (BN_is_zero(a)) 88 if (BN_is_zero(a))
89 *(p++) = '0'; 89 *(p++) = '0';