From 6fb57a92d19696c123d02d89cfa1f1e6703dfc32 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Fri, 18 May 2007 21:44:29 -0400 Subject: [PATCH] libblkid: Fix bug which could cuase bid_type to be corrupted 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" --- lib/blkid/ChangeLog | 6 ++++++ lib/blkid/tag.c | 16 ++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/blkid/ChangeLog b/lib/blkid/ChangeLog index 303f7cf..e33320a 100644 --- a/lib/blkid/ChangeLog +++ b/lib/blkid/ChangeLog @@ -1,3 +1,9 @@ +2007-05-18 Theodore Tso + + * 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 * cache.c (blkid_gc_cache): New function which removes any devices diff --git a/lib/blkid/tag.c b/lib/blkid/tag.c index c4e5c82..57277cd 100644 --- a/lib/blkid/tag.c +++ b/lib/blkid/tag.c @@ -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; -- 1.8.3.1