Bug 1308908 - Compare the whole accessible name when checking equality. r=tbsaunde

Use strcmp() instead of strncmp() when comparing the AtkObject name
before changing it.  9133117f410c06ad7fa25323a168bc97200043b9 changed
from Equals() to strncmp() to prevent issues related to embedded NUL
bytes, but the change lead to only checking if the AtkObject name has
the new value as prefix.  Instead, use strcmp() to check the whole
C strings, but still stopping at the first NUL byte in the new name.

strcmp() has to be safe here, as NS_ConvertUTF16toUTF8::get() has to
return a NUL-terminated string or the code would crash a few lines
below when calling strdup() on it.
This commit is contained in:
Colomban Wendling 2017-01-27 09:36:00 -05:00
Родитель c77b60e0a7
Коммит d8bb7d0fa3
1 изменённых файлов: 1 добавлений и 2 удалений

Просмотреть файл

@ -614,8 +614,7 @@ static void
MaybeFireNameChange(AtkObject* aAtkObj, const nsString& aNewName)
{
NS_ConvertUTF16toUTF8 newNameUTF8(aNewName);
if (aAtkObj->name &&
!strncmp(aAtkObj->name, newNameUTF8.get(), newNameUTF8.Length()))
if (aAtkObj->name && !strcmp(aAtkObj->name, newNameUTF8.get()))
return;
// Below we duplicate the functionality of atk_object_set_name(),