diff options
author | jsing <> | 2023-01-07 16:09:18 +0000 |
---|---|---|
committer | jsing <> | 2023-01-07 16:09:18 +0000 |
commit | b8509fbf001a81e19a6a7143b220201c9a6e3d1f (patch) | |
tree | f05bb6706ec0894829b1a92b70f6cb6b3b66e419 | |
parent | 60dc14000a90620806dda3865f2e4ba15b0498d9 (diff) | |
download | openbsd-b8509fbf001a81e19a6a7143b220201c9a6e3d1f.tar.gz openbsd-b8509fbf001a81e19a6a7143b220201c9a6e3d1f.tar.bz2 openbsd-b8509fbf001a81e19a6a7143b220201c9a6e3d1f.zip |
Use calloc() in BN_new(), rather than malloc() and then manually zeroing.
ok tb@
-rw-r--r-- | src/lib/libcrypto/bn/bn_lib.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/lib/libcrypto/bn/bn_lib.c b/src/lib/libcrypto/bn/bn_lib.c index eed7377cd9..e8397cafda 100644 --- a/src/lib/libcrypto/bn/bn_lib.c +++ b/src/lib/libcrypto/bn/bn_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bn_lib.c,v 1.68 2022/12/23 03:15:35 jsing Exp $ */ | 1 | /* $OpenBSD: bn_lib.c,v 1.69 2023/01/07 16:09:18 jsing 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 | * |
@@ -70,18 +70,15 @@ | |||
70 | BIGNUM * | 70 | BIGNUM * |
71 | BN_new(void) | 71 | BN_new(void) |
72 | { | 72 | { |
73 | BIGNUM *ret; | 73 | BIGNUM *bn; |
74 | 74 | ||
75 | if ((ret = malloc(sizeof(BIGNUM))) == NULL) { | 75 | if ((bn = calloc(1, sizeof(BIGNUM))) == NULL) { |
76 | BNerror(ERR_R_MALLOC_FAILURE); | 76 | BNerror(ERR_R_MALLOC_FAILURE); |
77 | return (NULL); | 77 | return NULL; |
78 | } | 78 | } |
79 | ret->flags = BN_FLG_MALLOCED; | 79 | bn->flags = BN_FLG_MALLOCED; |
80 | ret->top = 0; | 80 | |
81 | ret->neg = 0; | 81 | return bn; |
82 | ret->dmax = 0; | ||
83 | ret->d = NULL; | ||
84 | return (ret); | ||
85 | } | 82 | } |
86 | 83 | ||
87 | void | 84 | void |