summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2022-11-22 08:46:27 +0000
committertb <>2022-11-22 08:46:27 +0000
commit557f487f9c44f46bed80efc723cd9e9d13dbc7dc (patch)
treef42696a4af811afee474635778e409fa46dc8c09 /src
parentdb46b441d3b0b1cfbd7d103ff89510b12074254a (diff)
downloadopenbsd-557f487f9c44f46bed80efc723cd9e9d13dbc7dc.tar.gz
openbsd-557f487f9c44f46bed80efc723cd9e9d13dbc7dc.tar.bz2
openbsd-557f487f9c44f46bed80efc723cd9e9d13dbc7dc.zip
Fix segfaults in BN_dec2bn() and BN_hex2bn()
bn_print.c r1.29 added length checks to avoid overflowing the BIGNUM. If these checks are hit in length-only mode, i.e., bn is NULL, the error path dereferences bn. Change goto err to an early return to avoid this. ok jsing
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/bn/bn_print.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lib/libcrypto/bn/bn_print.c b/src/lib/libcrypto/bn/bn_print.c
index 9b5c753316..584903491f 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.33 2022/01/20 10:53:33 inoguchi Exp $ */ 1/* $OpenBSD: bn_print.c,v 1.34 2022/11/22 08:46:27 tb 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 *
@@ -205,7 +205,7 @@ BN_hex2bn(BIGNUM **bn, const char *a)
205 for (i = 0; i <= (INT_MAX / 4) && isxdigit((unsigned char)a[i]); i++) 205 for (i = 0; i <= (INT_MAX / 4) && isxdigit((unsigned char)a[i]); i++)
206 ; 206 ;
207 if (i > INT_MAX / 4) 207 if (i > INT_MAX / 4)
208 goto err; 208 return (0);
209 209
210 num = i + neg; 210 num = i + neg;
211 if (bn == NULL) 211 if (bn == NULL)
@@ -281,7 +281,7 @@ BN_dec2bn(BIGNUM **bn, const char *a)
281 for (i = 0; i <= (INT_MAX / 4) && isdigit((unsigned char)a[i]); i++) 281 for (i = 0; i <= (INT_MAX / 4) && isdigit((unsigned char)a[i]); i++)
282 ; 282 ;
283 if (i > INT_MAX / 4) 283 if (i > INT_MAX / 4)
284 goto err; 284 return (0);
285 285
286 num = i + neg; 286 num = i + neg;
287 if (bn == NULL) 287 if (bn == NULL)