summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2016-10-17 11:28:31 +0200
committerJo-Philipp Wich <jo@mein.io>2016-10-17 11:45:34 +0200
commitbd0221b884283361625e485840c99739c85d7b76 (patch)
tree03a21a35143954ba27156c42011d69f59e679742
parentc8c2aa3df24542a729129753d4b58e9e5027a288 (diff)
downloadfstools-bd0221b884283361625e485840c99739c85d7b76.tar.gz
libblkid-tiny: avoid setting phantom UUIDs
When blkid_probe_set_uuid_as() is invoked with a non-NULL name parameter then the name parameter denotes the kind of UUID (like "EXT_JOURNAL") not the name of the file system. Only copy the UUID value to the probe uuid member if the given name is either NULL or "UUID". Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r--libblkid-tiny/libblkid-tiny.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/libblkid-tiny/libblkid-tiny.c b/libblkid-tiny/libblkid-tiny.c
index 9f260eb..d718a1e 100644
--- a/libblkid-tiny/libblkid-tiny.c
+++ b/libblkid-tiny/libblkid-tiny.c
@@ -125,13 +125,12 @@ int blkid_probe_set_uuid_as(blkid_probe pr, unsigned char *uuid, const char *nam
{
short unsigned int*u = (short unsigned int*) uuid;
- if (u[0])
+ if (u[0] && (!name || !strcmp(name, "UUID"))) {
sprintf(pr->uuid,
"%04x%04x-%04x-%04x-%04x-%04x%04x%04x",
be16_to_cpu(u[0]), be16_to_cpu(u[1]), be16_to_cpu(u[2]), be16_to_cpu(u[3]),
be16_to_cpu(u[4]), be16_to_cpu(u[5]), be16_to_cpu(u[6]), be16_to_cpu(u[7]));
- if (name)
- strncpy(pr->name, name, sizeof(pr->name));
+ }
return 0;
}