diff options
author | Thomas Haller <thaller@redhat.com> | 2022-06-24 10:17:14 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2022-06-24 21:15:11 +0200 |
commit | e3a015714160a8a6bae995f937a2c6a54c804052 (patch) | |
tree | 25ca0f4ddecde5c469e8a471a6c712c3d85af579 | |
parent | 2dd76e6b989b0086b9dcc9946098f9f91ced28cd (diff) | |
download | NetworkManager-e3a015714160a8a6bae995f937a2c6a54c804052.tar.gz |
glib-aux: pass string length to nm_uuid_generate_from_string() in nm_uuid_is_valid_nm()
No need to recompute the length. We have it already.
Also no need to NUL terminate the string.
-rw-r--r-- | src/libnm-glib-aux/nm-uuid.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/libnm-glib-aux/nm-uuid.c b/src/libnm-glib-aux/nm-uuid.c index ff0649d0fe..2b4001f23b 100644 --- a/src/libnm-glib-aux/nm-uuid.c +++ b/src/libnm-glib-aux/nm-uuid.c @@ -235,24 +235,23 @@ nm_uuid_is_valid_nm(const char *str, * are made lower case first. */ NM_SET_OUT(out_normalized, TRUE); if (out_normalized_str) { - char str_lower[40 + 1]; + char str_lower[40]; int i; - nm_assert(strlen(str) < G_N_ELEMENTS(str_lower)); + nm_assert(strlen(str) <= G_N_ELEMENTS(str_lower)); /* normalize first to lower-case. */ for (i = 0; str[i]; i++) { nm_assert(i < G_N_ELEMENTS(str_lower)); str_lower[i] = g_ascii_tolower(str[i]); } - nm_assert(i < G_N_ELEMENTS(str_lower)); - str_lower[i] = '\0'; + nm_assert(i <= G_N_ELEMENTS(str_lower)); /* The namespace UUID is chosen randomly. */ nm_uuid_generate_from_string( &uuid, str_lower, - -1, + i, NM_UUID_TYPE_VERSION5, &NM_UUID_INIT(4e, 72, f7, 09, ca, 95, 44, 05, 90, 53, 1f, 43, 29, 4a, 61, 8c)); nm_uuid_unparse(&uuid, out_normalized_str); |