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); }