]> sourceware.org Git - lvm2.git/commitdiff
Fix reading byte from char params[-1] position
authorZdenek Kabelac <zkabelac@redhat.com>
Tue, 8 Mar 2011 22:43:19 +0000 (22:43 +0000)
committerZdenek Kabelac <zkabelac@redhat.com>
Tue, 8 Mar 2011 22:43:19 +0000 (22:43 +0000)
When the ->params string is empty - memory access is made on the byte
before allocated buffer (catched by valgrind) - in the case it would
constain 0x20 - it would even overwrite this buffer.
So fix by checking len > 0 before doing such access.
Also slightly optimise this loop from repeated strlen call.

WHATS_NEW_DM
libdm/ioctl/libdm-iface.c

index 59f43666b65817fddef3f8ea0936c5ce0970d8f7..4c3ac0aa220a75a8a02317750e3191c60258df12 100644 (file)
@@ -1,5 +1,6 @@
 Version 1.02.64 - 
 ===================================
+  Fix memory access of empty params string in _reload_with_suppression_v4().
   Lower severity of selabel_lookup and matchpathcon failure to log_debug.
   Accept multiple mapped device names on many dmsetup command lines.
   Fix dm_udev_wait calls in dmsetup to occur before readahead display not after.
index 8755f59b288056ebfd6809f8897d033a633bb201..241e7927c33f44eb621f6b02896830b9e311d8d9 100644 (file)
@@ -1836,6 +1836,7 @@ static int _reload_with_suppression_v4(struct dm_task *dmt)
 {
        struct dm_task *task;
        struct target *t1, *t2;
+       size_t len;
        int r;
 
        /* New task to get existing table information */
@@ -1878,8 +1879,9 @@ static int _reload_with_suppression_v4(struct dm_task *dmt)
        t2 = task->head;
 
        while (t1 && t2) {
-               while (t2->params[strlen(t2->params) - 1] == ' ')
-                       t2->params[strlen(t2->params) - 1] = '\0';
+               len = strlen(t2->params);
+               while (len-- > 0 && t2->params[len] == ' ')
+                       t2->params[len] = '\0';
                if ((t1->start != t2->start) ||
                    (t1->length != t2->length) ||
                    (strcmp(t1->type, t2->type)) ||
This page took 0.044222 seconds and 5 git commands to generate.