1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-11 05:17:44 +03:00

creds-util: fix possible divide-by-zero

input_size may be zero.

Fixes #20469.
This commit is contained in:
Yu Watanabe 2021-08-18 16:05:02 +09:00 committed by Lennart Poettering
parent 87167331c9
commit 7ff592a454

View File

@ -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);
}