From 394615c62f8256adba3191f1bc01d93c747b974b Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Thu, 21 Feb 2019 19:51:32 +0200 Subject: SL-10565 LLMachineID crashes --- indra/newview/llmachineid.cpp | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'indra/newview/llmachineid.cpp') diff --git a/indra/newview/llmachineid.cpp b/indra/newview/llmachineid.cpp index b0ee8e7fcb..2001359e50 100644 --- a/indra/newview/llmachineid.cpp +++ b/indra/newview/llmachineid.cpp @@ -65,11 +65,11 @@ public: S32 LLMachineID::init() { - memset(static_unique_id,0,sizeof(static_unique_id)); + size_t len = sizeof(static_unique_id); + memset(static_unique_id, 0, len); S32 ret_code = 0; #if LL_WINDOWS # pragma comment(lib, "wbemuuid.lib") - size_t len = sizeof(static_unique_id); // algorithm to detect BIOS serial number found at: // http://msdn.microsoft.com/en-us/library/aa394077%28VS.85%29.aspx @@ -218,16 +218,19 @@ S32 LLMachineID::init() // Get the value of the Name property hr = pclsObj->Get(L"SerialNumber", 0, &vtProp, 0, 0); LL_INFOS("AppInit") << " Serial Number : " << vtProp.bstrVal << LL_ENDL; + // use characters in the returned Serial Number to create a byte array of size len BSTR serialNumber ( vtProp.bstrVal); + unsigned int serial_size = SysStringLen(serialNumber); unsigned int j = 0; - while( vtProp.bstrVal[j] != 0) + + while (j < serial_size) { for (unsigned int i = 0; i < len; i++) { - if (vtProp.bstrVal[j] == 0) + if (j >= serial_size) break; - + static_unique_id[i] = (unsigned int)(static_unique_id[i] + serialNumber[j]); j++; } @@ -254,16 +257,8 @@ S32 LLMachineID::init() ret_code = LLUUID::getNodeID(staticPtr); #endif has_static_unique_id = true; - return ret_code; -} - -S32 LLMachineID::getUniqueID(unsigned char *unique_id, size_t len) -{ - if (has_static_unique_id) - { - memcpy ( unique_id, &static_unique_id, len); - LL_INFOS_ONCE("AppInit") << "UniqueID: 0x"; + LL_INFOS("AppInit") << "UniqueID: 0x"; // Code between here and LL_ENDL is not executed unless the LL_DEBUGS // actually produces output for (size_t i = 0; i < len; ++i) @@ -271,11 +266,21 @@ S32 LLMachineID::getUniqueID(unsigned char *unique_id, size_t len) // Copy each char to unsigned int to hexify. Sending an unsigned // char to a std::ostream tries to represent it as a char, not // what we want here. - unsigned byte = unique_id[i]; + unsigned byte = static_unique_id[i]; LL_CONT << std::hex << std::setw(2) << std::setfill('0') << byte; } // Reset default output formatting to avoid nasty surprises! LL_CONT << std::dec << std::setw(0) << std::setfill(' ') << LL_ENDL; + + return ret_code; +} + + +S32 LLMachineID::getUniqueID(unsigned char *unique_id, size_t len) +{ + if (has_static_unique_id) + { + memcpy ( unique_id, &static_unique_id, len); return 1; } return 0; -- cgit v1.2.3 From 47bb094b4760133628ad41cd65eb272eeae6f295 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Tue, 30 Apr 2019 15:23:06 +0300 Subject: SL-10565 LLMachineID crashes --- indra/newview/llmachineid.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llmachineid.cpp') diff --git a/indra/newview/llmachineid.cpp b/indra/newview/llmachineid.cpp index 2001359e50..c667b0af3f 100644 --- a/indra/newview/llmachineid.cpp +++ b/indra/newview/llmachineid.cpp @@ -224,11 +224,11 @@ S32 LLMachineID::init() unsigned int serial_size = SysStringLen(serialNumber); unsigned int j = 0; - while (j < serial_size) + while (j < serial_size && vtProp.bstrVal[j] != 0) { for (unsigned int i = 0; i < len; i++) { - if (j >= serial_size) + if (j >= serial_size || vtProp.bstrVal[j] == 0) break; static_unique_id[i] = (unsigned int)(static_unique_id[i] + serialNumber[j]); -- cgit v1.2.3 From 3961a9e80a5c46d969f34775483f0e7aa0dfb84c Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Tue, 30 Apr 2019 15:24:49 +0300 Subject: SL-11061 Viewer crashes on launch if serial is either unset or does not return a string --- indra/newview/llmachineid.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'indra/newview/llmachineid.cpp') diff --git a/indra/newview/llmachineid.cpp b/indra/newview/llmachineid.cpp index c667b0af3f..51127928d1 100644 --- a/indra/newview/llmachineid.cpp +++ b/indra/newview/llmachineid.cpp @@ -217,6 +217,13 @@ S32 LLMachineID::init() // Get the value of the Name property hr = pclsObj->Get(L"SerialNumber", 0, &vtProp, 0, 0); + if (FAILED(hr)) + { + LL_WARNS() << "Failed to get SerialNumber. Error code = 0x" << hex << hres << LL_ENDL; + pclsObj->Release(); + pclsObj = NULL; + continue; + } LL_INFOS("AppInit") << " Serial Number : " << vtProp.bstrVal << LL_ENDL; // use characters in the returned Serial Number to create a byte array of size len -- cgit v1.2.3