summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2022-01-27 14:35:38 +0100
committerThomas Haller <thaller@redhat.com>2022-01-27 14:35:38 +0100
commit6ae6edb6a80da8cd2c06a3cbc262fdd646f709c2 (patch)
treeed8544c8510bd78829ef639191358d26bb7a285f
parentb755539aa6ff56f9b7164db77cc0f9bc979ef984 (diff)
glib-aux/trival: add code comment to nm_ref_string_equal_str()
-rw-r--r--src/libnm-glib-aux/nm-ref-string.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/libnm-glib-aux/nm-ref-string.h b/src/libnm-glib-aux/nm-ref-string.h
index 577786acef..3363bce00a 100644
--- a/src/libnm-glib-aux/nm-ref-string.h
+++ b/src/libnm-glib-aux/nm-ref-string.h
@@ -136,6 +136,9 @@ nm_ref_string_equal_str(NMRefString *rstr, const char *str)
if (!rstr)
return FALSE;
+ /* We don't use streq() here, because an NMRefString might have embedded NUL characters
+ * (as the length is tracked separately). The NUL terminated C string @str must not
+ * compare equal to such a @rstr, thus we first explicitly check strlen(). */
return rstr->len == strlen(str) && (rstr->str == str || memcmp(rstr->str, str, rstr->len) == 0);
}