diff options
author | jsing <> | 2022-12-23 02:27:47 +0000 |
---|---|---|
committer | jsing <> | 2022-12-23 02:27:47 +0000 |
commit | db6281c6da9f0680a4284ec6cb9ea68ce90b7399 (patch) | |
tree | 5f0a4566c9ac8eff6a526600541bf77ec0648bf9 /src | |
parent | 9902ad884661178b3f5d08fc01069eb4c1b2ba95 (diff) | |
download | openbsd-db6281c6da9f0680a4284ec6cb9ea68ce90b7399.tar.gz openbsd-db6281c6da9f0680a4284ec6cb9ea68ce90b7399.tar.bz2 openbsd-db6281c6da9f0680a4284ec6cb9ea68ce90b7399.zip |
Fix an unchecked strdup() in UI_create_method().
ok tb@
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/ui/ui_lib.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/lib/libcrypto/ui/ui_lib.c b/src/lib/libcrypto/ui/ui_lib.c index e36c270a87..8811bf86c7 100644 --- a/src/lib/libcrypto/ui/ui_lib.c +++ b/src/lib/libcrypto/ui/ui_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ui_lib.c,v 1.48 2022/12/23 02:26:16 jsing Exp $ */ | 1 | /* $OpenBSD: ui_lib.c,v 1.49 2022/12/23 02:27:47 jsing Exp $ */ |
2 | /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL | 2 | /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL |
3 | * project 2001. | 3 | * project 2001. |
4 | */ | 4 | */ |
@@ -561,16 +561,25 @@ UI_set_method(UI *ui, const UI_METHOD *meth) | |||
561 | } | 561 | } |
562 | LCRYPTO_ALIAS(UI_set_method) | 562 | LCRYPTO_ALIAS(UI_set_method) |
563 | 563 | ||
564 | |||
565 | UI_METHOD * | 564 | UI_METHOD * |
566 | UI_create_method(const char *name) | 565 | UI_create_method(const char *name) |
567 | { | 566 | { |
568 | UI_METHOD *ui_method = calloc(1, sizeof(UI_METHOD)); | 567 | UI_METHOD *method = NULL; |
568 | |||
569 | if ((method = calloc(1, sizeof(UI_METHOD))) == NULL) | ||
570 | goto err; | ||
569 | 571 | ||
570 | if (ui_method && name) | 572 | if (name != NULL) { |
571 | ui_method->name = strdup(name); | 573 | if ((method->name = strdup(name)) == NULL) |
574 | goto err; | ||
575 | } | ||
572 | 576 | ||
573 | return ui_method; | 577 | return method; |
578 | |||
579 | err: | ||
580 | UI_destroy_method(method); | ||
581 | |||
582 | return NULL; | ||
574 | } | 583 | } |
575 | LCRYPTO_ALIAS(UI_create_method) | 584 | LCRYPTO_ALIAS(UI_create_method) |
576 | 585 | ||