From 72e7b345e216bb1b4ca7294813fa4b5054358242 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Thomas=20Wei=C3=9Fschuh?= Date: Wed, 17 Apr 2024 09:27:08 +0200 Subject: [PATCH] uuidparse: only report type/version for DCE variant MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The type/version is only defined in scope for the DCE variant. From RFC4122 Section 4.1.1: "the interpretation of all other bits in the UUID depends on the setting of the bits in the variant field." Signed-off-by: Thomas Weißschuh --- misc-utils/uuidparse.c | 2 ++ tests/expected/uuid/uuidparse | 42 +++++++++++++++++------------------ 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/misc-utils/uuidparse.c b/misc-utils/uuidparse.c index 2dd7fb3888..33d961c922 100644 --- a/misc-utils/uuidparse.c +++ b/misc-utils/uuidparse.c @@ -191,6 +191,8 @@ static void fill_table_row(struct libscols_table *tb, char const *const uuid) str = xstrdup(_("invalid")); break; } + if (variant != UUID_VARIANT_DCE) + break; switch (type) { case UUID_TYPE_DCE_NIL: if (uuid_is_null(buf)) diff --git a/tests/expected/uuid/uuidparse b/tests/expected/uuid/uuidparse index 8b23a25487..5cac367559 100644 --- a/tests/expected/uuid/uuidparse +++ b/tests/expected/uuid/uuidparse @@ -1,31 +1,31 @@ UUID VARIANT TYPE TIME -00000000-0000-0000-0000-000000000000 NCS nil -00000000-0000-1000-0000-000000000000 NCS time-based -00000000-0000-2000-0000-000000000000 NCS DCE -00000000-0000-3000-0000-000000000000 NCS name-based -00000000-0000-4000-0000-000000000000 NCS random -00000000-0000-5000-0000-000000000000 NCS sha1-based -00000000-0000-6000-0000-000000000000 NCS unknown +00000000-0000-0000-0000-000000000000 NCS +00000000-0000-1000-0000-000000000000 NCS +00000000-0000-2000-0000-000000000000 NCS +00000000-0000-3000-0000-000000000000 NCS +00000000-0000-4000-0000-000000000000 NCS +00000000-0000-5000-0000-000000000000 NCS +00000000-0000-6000-0000-000000000000 NCS 00000000-0000-0000-8000-000000000000 DCE unknown 00000000-0000-2000-8000-000000000000 DCE DCE 00000000-0000-3000-8000-000000000000 DCE name-based 00000000-0000-4000-8000-000000000000 DCE random 00000000-0000-5000-8000-000000000000 DCE sha1-based 00000000-0000-6000-8000-000000000000 DCE unknown -00000000-0000-0000-d000-000000000000 Microsoft unknown -00000000-0000-1000-d000-000000000000 Microsoft time-based -00000000-0000-2000-d000-000000000000 Microsoft DCE -00000000-0000-3000-d000-000000000000 Microsoft name-based -00000000-0000-4000-d000-000000000000 Microsoft random -00000000-0000-5000-d000-000000000000 Microsoft sha1-based -00000000-0000-6000-d000-000000000000 Microsoft unknown -00000000-0000-0000-f000-000000000000 other unknown -00000000-0000-1000-f000-000000000000 other time-based -00000000-0000-2000-f000-000000000000 other DCE -00000000-0000-3000-f000-000000000000 other name-based -00000000-0000-4000-f000-000000000000 other random -00000000-0000-5000-f000-000000000000 other sha1-based -00000000-0000-6000-f000-000000000000 other unknown +00000000-0000-0000-d000-000000000000 Microsoft +00000000-0000-1000-d000-000000000000 Microsoft +00000000-0000-2000-d000-000000000000 Microsoft +00000000-0000-3000-d000-000000000000 Microsoft +00000000-0000-4000-d000-000000000000 Microsoft +00000000-0000-5000-d000-000000000000 Microsoft +00000000-0000-6000-d000-000000000000 Microsoft +00000000-0000-0000-f000-000000000000 other +00000000-0000-1000-f000-000000000000 other +00000000-0000-2000-f000-000000000000 other +00000000-0000-3000-f000-000000000000 other +00000000-0000-4000-f000-000000000000 other +00000000-0000-5000-f000-000000000000 other +00000000-0000-6000-f000-000000000000 other 9b274c46-544a-11e7-a972-00037f500001 DCE time-based 2017-06-18 17:21:46,544647+00:00 invalid-input invalid invalid invalid return value: 0 -- 2.39.5