Fix debug message printing LUKS2 checksum.

The trailing NUL is written already by snprintf, moreover,
it is written on wrong place here.

Just rely on snprintf here.

Fixes: #685.
This commit is contained in:
Milan Broz
2021-11-09 15:29:49 +01:00
parent 26a3f3b058
commit 0cc5f2fdf9

View File

@@ -62,8 +62,8 @@ static void log_dbg_checksum(struct crypt_device *cd,
int i;
for (i = 0; i < crypt_hash_size(csum_alg); i++)
snprintf(&csum_txt[i*2], 3, "%02hhx", (const char)csum[i]);
csum_txt[i*2+1] = '\0'; /* Just to be safe, sprintf should write \0 there. */
if (snprintf(&csum_txt[i*2], 3, "%02hhx", (const char)csum[i]) != 2)
return;
log_dbg(cd, "Checksum:%s (%s)", &csum_txt[0], info);
}