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

Check for version string buffer

Since lvm seems to call driver_version(NULL, 0)  this would lead
to crash. Though the combination of the code is probably very hard to hit.
If the user doesn't supply version buffer, just skip printing to buffer.
This commit is contained in:
Zdenek Kabelac 2012-03-01 10:07:38 +00:00
parent f9467799c1
commit 521ddeaecc
2 changed files with 12 additions and 3 deletions

View File

@ -1,5 +1,6 @@
Version 1.02.73 -
====================================
Support dm_task_get_driver_version() query without version string.
Log failure of pthread_join when cleaning unused threads in dmeventd.
Fix empty string warning logic in _find_config_str. (1.02.68)
Fix dm_task_set_name to properly resolve path to dm name (1.02.71).

View File

@ -467,14 +467,21 @@ int dm_task_get_driver_version(struct dm_task *dmt, char *version, size_t size)
unsigned *v;
if (!dmt->dmi.v4) {
version[0] = '\0';
if (version)
version[0] = '\0';
return 0;
}
v = dmt->dmi.v4->version;
snprintf(version, size, "%u.%u.%u", v[0], v[1], v[2]);
_dm_version_minor = v[1];
_dm_version_patchlevel = v[2];
if (version &&
(snprintf(version, size, "%u.%u.%u", v[0], v[1], v[2]) < 0)) {
log_error("Buffer for version is to short.");
if (size > 0)
version[0] = '\0'
return 0;
}
return 1;
}
@ -494,7 +501,8 @@ static int _check_version(char *version, size_t size, int log_suppress)
_log_suppress = 1;
r = dm_task_run(task);
dm_task_get_driver_version(task, version, size);
if (!dm_task_get_driver_version(task, version, size))
stack;
dm_task_destroy(task);
_log_suppress = 0;