mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-18 22:30:07 +01:00
Fix debugging messages callback.
The debug messages should contain EOL char. Also check string lengths in internal logging macros.
This commit is contained in:
@@ -175,12 +175,15 @@ void logger(struct crypt_device *cd, int level, const char *file,
|
||||
{
|
||||
va_list argp;
|
||||
char target[LOG_MAX_LEN + 2];
|
||||
int len;
|
||||
|
||||
va_start(argp, format);
|
||||
|
||||
if (vsnprintf(&target[0], LOG_MAX_LEN, format, argp) > 0 ) {
|
||||
len = vsnprintf(&target[0], LOG_MAX_LEN, format, argp);
|
||||
if (len > 0 && len < LOG_MAX_LEN) {
|
||||
/* All verbose and error messages in tools end with EOL. */
|
||||
if (level == CRYPT_LOG_VERBOSE || level == CRYPT_LOG_ERROR)
|
||||
if (level == CRYPT_LOG_VERBOSE || level == CRYPT_LOG_ERROR ||
|
||||
level == CRYPT_LOG_DEBUG || level == CRYPT_LOG_DEBUG_JSON)
|
||||
strncat(target, "\n", LOG_MAX_LEN);
|
||||
|
||||
crypt_log(cd, level, target);
|
||||
|
||||
@@ -116,7 +116,7 @@ void tool_log(int level, const char *msg, void *usrptr __attribute__((unused)))
|
||||
case CRYPT_LOG_DEBUG_JSON:
|
||||
case CRYPT_LOG_DEBUG:
|
||||
if (opt_debug)
|
||||
fprintf(stdout, "# %s\n", msg);
|
||||
fprintf(stdout, "# %s", msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user