From: Theodore Ts'o Date: Sat, 7 Jul 2007 22:32:26 +0000 (-0400) Subject: Fix bug which could cause libblkid to loop forever X-Git-Tag: v1.40.1~8 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=ac7dd696d60a2cb6d27c2c4855fefc7b26a26d72;p=tools%2Fe2fsprogs.git Fix bug which could cause libblkid to loop forever When revalidating a partition where there is obsolete information in /etc/blkid.tab, we end up freeing a the type tag without clearing dev->bid_type, causing blkid_verify() to loop forever. Addresses-Debian-Bug: #432052 Signed-off-by: "Theodore Ts'o" --- diff --git a/lib/blkid/tag.c b/lib/blkid/tag.c index 57277cd..44dd86d 100644 --- a/lib/blkid/tag.c +++ b/lib/blkid/tag.c @@ -132,6 +132,7 @@ int blkid_set_tag(blkid_dev dev, const char *name, { blkid_tag t = 0, head = 0; char *val = 0; + char **dev_var = 0; if (!dev || !name) return -BLKID_ERR_PARAM; @@ -139,6 +140,18 @@ int blkid_set_tag(blkid_dev dev, const char *name, if (!(val = blkid_strndup(value, vlength)) && value) return -BLKID_ERR_MEM; + /* + * Certain common tags are linked directly to the device struct + * We need to know what they are before we do anything else because + * the function name parameter might get freed later on. + */ + if (!strcmp(name, "TYPE")) + dev_var = &dev->bid_type; + else if (!strcmp(name, "LABEL")) + dev_var = &dev->bid_label; + else if (!strcmp(name, "UUID")) + dev_var = &dev->bid_uuid; + t = blkid_find_tag_dev(dev, name); if (!value) { if (t) @@ -182,12 +195,8 @@ 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_var) + *dev_var = val; if (dev->bid_cache) dev->bid_cache->bic_flags |= BLKID_BIC_FL_CHANGED;