Whamcloud - gitweb
libblkid: Fix bug which could cuase bid_type to be corrupted
authorTheodore Ts'o <tytso@mit.edu>
Sat, 19 May 2007 01:44:29 +0000 (21:44 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 19 May 2007 01:44:29 +0000 (21:44 -0400)
Fortunately bid_type isn't used much, and bid_label and bid_uuid is
only used by debugging code, so the impact of this bug was very
minor.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lib/blkid/ChangeLog
lib/blkid/tag.c

index 303f7cf..e33320a 100644 (file)
@@ -1,3 +1,9 @@
+2007-05-18  Theodore Tso  <tytso@mit.edu>
+
+       * tag.c (blkid_set_tag): Fix bug where bid_type, bid_label, and
+               bid_uuid could get corrupted if their corresponding tag is
+               set to its original value using blkid_set_tag().
+
 2007-05-17  Theodore Tso  <tytso@mit.edu>
 
        * cache.c (blkid_gc_cache): New function which removes any devices
index c4e5c82..57277cd 100644 (file)
@@ -139,14 +139,6 @@ int blkid_set_tag(blkid_dev dev, const char *name,
        if (!(val = blkid_strndup(value, vlength)) && value)
                return -BLKID_ERR_MEM;
 
-       /* Link common tags directly to the device struct */
-       if (!strcmp(name, "TYPE"))
-               dev->bid_type = val;
-       else if (!strcmp(name, "LABEL"))
-               dev->bid_label = val;
-       else if (!strcmp(name, "UUID"))
-               dev->bid_uuid = val;
-               
        t = blkid_find_tag_dev(dev, name);
        if (!value) {
                if (t)
@@ -189,6 +181,14 @@ int blkid_set_tag(blkid_dev dev, const char *name,
                }
        }
        
+       /* Link common tags directly to the device struct */
+       if (!strcmp(name, "TYPE"))
+               dev->bid_type = val;
+       else if (!strcmp(name, "LABEL"))
+               dev->bid_label = val;
+       else if (!strcmp(name, "UUID"))
+               dev->bid_uuid = val;
+               
        if (dev->bid_cache)
                dev->bid_cache->bic_flags |= BLKID_BIC_FL_CHANGED;
        return 0;