diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-08-18 09:05:02 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2021-08-19 09:49:00 +0200 |
commit | 7ff592a4542f611088e63ab27191a40fcd064e7c (patch) | |
tree | dfcab3cc7e6fa7452eaefdbd8e2abe553764db02 /src/shared/creds-util.c | |
parent | sd-boot: Use UEFI provided CRC32 (diff) | |
download | systemd-7ff592a4542f611088e63ab27191a40fcd064e7c.tar.xz systemd-7ff592a4542f611088e63ab27191a40fcd064e7c.zip |
creds-util: fix possible divide-by-zero
input_size may be zero.
Fixes #20469.
Diffstat (limited to '')
-rw-r--r-- | src/shared/creds-util.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/shared/creds-util.c b/src/shared/creds-util.c index 3bc5fbef51..9980cd93a9 100644 --- a/src/shared/creds-util.c +++ b/src/shared/creds-util.c @@ -667,11 +667,11 @@ int encrypt_credential_and_warn( p += tsz; assert(p <= output_size); - if (DEBUG_LOGGING) { + if (DEBUG_LOGGING && input_size > 0) { size_t base64_size; base64_size = DIV_ROUND_UP(p * 4, 3); /* Include base64 size increase in debug output */ - + assert(base64_size >= input_size); log_debug("Input of %zu bytes grew to output of %zu bytes (+%2zu%%).", input_size, base64_size, base64_size * 100 / input_size - 100); } |