From 07002f73206dae39f906e6fae6e7c6ca79670c36 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sat, 5 Jun 2021 16:55:04 +0200 Subject: [PATCH] core: remove _nul_sentinel from UuidData struct The user really must not treat UuidData.bin as a NUL terminated string. The _nul_sentinel is not necessary. And if by chance the user makes this fatal mistake, then UuidData.str will still be there to NUL terminate the buffer, the content is garbage either way. Remove the sentinel. --- src/core/nm-core-utils.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/core/nm-core-utils.c b/src/core/nm-core-utils.c index bb2471c6a4..13400f4be2 100644 --- a/src/core/nm-core-utils.c +++ b/src/core/nm-core-utils.c @@ -2377,8 +2377,6 @@ out: typedef struct { NMUuid bin; - char - _nul_sentinel; /* just for safety, if somebody accidentally uses the binary in a string context. */ /* depending on whether the string is packed or not (with/without hyphens), * it's 32 or 36 characters long (plus the trailing NUL). @@ -2396,9 +2394,8 @@ _uuid_data_init(UuidData *uuid_data, gboolean packed, gboolean is_fake, const NM nm_assert(uuid_data); nm_assert(uuid); - uuid_data->bin = *uuid; - uuid_data->_nul_sentinel = '\0'; - uuid_data->is_fake = is_fake; + uuid_data->bin = *uuid; + uuid_data->is_fake = is_fake; if (packed) { G_STATIC_ASSERT_EXPR(sizeof(uuid_data->str) >= (sizeof(*uuid) * 2 + 1)); nm_utils_bin2hexstr_full(uuid, sizeof(*uuid), '\0', FALSE, uuid_data->str);