diff options
| author | Eugene Syromiatnikov <[email protected]> | 2025-09-15 05:14:09 +0200 |
|---|---|---|
| committer | Tomas Mraz <[email protected]> | 2025-09-25 16:59:52 +0200 |
| commit | 61422fd7e084e63f050ceabf1b0debff801f10ab (patch) | |
| tree | 0834c4f20d76e8452196d62ba10bd22d7bc5fc42 | |
| parent | crypto/evp/ctrl_params_translate.c: fix a typo in the error message (diff) | |
| download | openssl-61422fd7e084e63f050ceabf1b0debff801f10ab.tar.gz openssl-61422fd7e084e63f050ceabf1b0debff801f10ab.zip | |
apps/storeutl.c: avoid signed integer overflow in indent_printf()
As two arbitrarily large printf return values can trigger signed integer
overflow, rewrite the return value handling to avoid it.
Fixes: fb43ddceda79 "Add a recursive option to 'openssl storeutl'"
Resolves: https://scan5.scan.coverity.com/#/project-view/65248/10222?selectedIssue=1665428
References: https://github.com/openssl/project/issues/1432
Signed-off-by: Eugene Syromiatnikov <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from https://github.com/openssl/openssl/pull/28648)
| -rw-r--r-- | apps/storeutl.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/apps/storeutl.c b/apps/storeutl.c index 1594a9bb756..afa4f47b81b 100644 --- a/apps/storeutl.c +++ b/apps/storeutl.c @@ -334,14 +334,22 @@ int storeutl_main(int argc, char *argv[]) static int indent_printf(int indent, BIO *bio, const char *format, ...) { va_list args; - int ret; + int ret, vret; + + ret = BIO_printf(bio, "%*s", indent, ""); + if (ret < 0) + return ret; va_start(args, format); + vret = BIO_vprintf(bio, format, args); + va_end(args); - ret = BIO_printf(bio, "%*s", indent, "") + BIO_vprintf(bio, format, args); + if (vret < 0) + return vret; + if (vret > INT_MAX - ret) + return INT_MAX; - va_end(args); - return ret; + return ret + vret; } static int process(const char *uri, const UI_METHOD *uimeth, PW_CB_DATA *uidata, |
