summaryrefslogtreecommitdiffstats
path: root/libdm
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2012-03-01 10:07:38 +0000
committerZdenek Kabelac <zkabelac@redhat.com>2012-03-01 10:07:38 +0000
commit521ddeaecc7fb6eba0111fd82704abc03ebe81c7 (patch)
tree0be3494f183a0055e2552d8c35fa156201bacf84 /libdm
parentf9467799c171d66fe7f73a095050f8a08149b7b6 (diff)
downloadlvm2-521ddeaecc7fb6eba0111fd82704abc03ebe81c7.tar.gz
lvm2-521ddeaecc7fb6eba0111fd82704abc03ebe81c7.tar.xz
lvm2-521ddeaecc7fb6eba0111fd82704abc03ebe81c7.zip
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.
Diffstat (limited to 'libdm')
-rw-r--r--libdm/ioctl/libdm-iface.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/libdm/ioctl/libdm-iface.c b/libdm/ioctl/libdm-iface.c
index f6795997..2d2be416 100644
--- a/libdm/ioctl/libdm-iface.c
+++ b/libdm/ioctl/libdm-iface.c
@@ -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;