1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

libdm: validate vsnprintf

Avoid using buffer when no output has been generated.
Missed in ee13f265f0.
This commit is contained in:
Zdenek Kabelac 2016-12-09 22:54:08 +01:00
parent 3903f915f8
commit 6f84d3c69c
2 changed files with 9 additions and 4 deletions

View File

@ -1,5 +1,6 @@
Version 1.02.138 -
=====================================
Validation vsnprintf result in runtime translate of dm_log (1.02.136).
Separate filemap extent allocation from region table.
Fix segmentation fault when filemap region creation fails
Fix performance of region cleanup for failed filemap creation.

View File

@ -173,14 +173,16 @@ static void _log_to_default_log(int level,
const char *file, int line, int dm_errno_or_class,
const char *f, ...)
{
int n;
va_list ap;
char buf[2 * PATH_MAX + 256]; /* big enough for most messages */
va_start(ap, f);
vsnprintf(buf, sizeof(buf), f, ap);
n = vsnprintf(buf, sizeof(buf), f, ap);
va_end(ap);
dm_log(level, file, line, "%s", buf);
if (n > 0) /* Could be truncated */
dm_log(level, file, line, "%s", buf);
}
/*
@ -195,14 +197,16 @@ __attribute__((format(printf, 4, 5)))
static void _log_to_default_log_with_errno(int level,
const char *file, int line, const char *f, ...)
{
int n;
va_list ap;
char buf[2 * PATH_MAX + 256]; /* big enough for most messages */
va_start(ap, f);
vsnprintf(buf, sizeof(buf), f, ap);
n = vsnprintf(buf, sizeof(buf), f, ap);
va_end(ap);
dm_log_with_errno(level, file, line, 0, "%s", buf);
if (n > 0) /* Could be truncated */
dm_log_with_errno(level, file, line, 0, "%s", buf);
}
void dm_log_init(dm_log_fn fn)