From: Yu Watanabe Date: Wed, 18 Aug 2021 07:05:02 +0000 (+0900) Subject: creds-util: fix possible divide-by-zero X-Git-Tag: v250-rc1~807 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7ff592a4542f611088e63ab27191a40fcd064e7c;p=thirdparty%2Fsystemd.git creds-util: fix possible divide-by-zero input_size may be zero. Fixes #20469. --- diff --git a/src/shared/creds-util.c b/src/shared/creds-util.c index 3bc5fbef512..9980cd93a92 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); }