From d8bb7d0fa35fd733d214db06e6857b184cbff9d2 Mon Sep 17 00:00:00 2001 From: Colomban Wendling Date: Fri, 27 Jan 2017 09:36:00 -0500 Subject: [PATCH] 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. --- accessible/atk/AccessibleWrap.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/accessible/atk/AccessibleWrap.cpp b/accessible/atk/AccessibleWrap.cpp index 9b8c5037c979..faf64b9c386a 100644 --- a/accessible/atk/AccessibleWrap.cpp +++ b/accessible/atk/AccessibleWrap.cpp @@ -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(),