From 10231180a83e2002a0fe9d175bf22d4ae71f0601 Mon Sep 17 00:00:00 2001 From: "U-BASIS\\cray" <cray@hpa-win7-mtg1.basistech.net> Date: Tue, 8 Jan 2019 08:58:23 -0500 Subject: [PATCH] Fix for CT-2917 - fail to get non-ascii registry key names Non-ascii registry key names seem to not be Null terminated. I created three non-ascii keys all of which had no Null termination. I verified manually using a hex editor on the registry hive. This led to conversion issues when calling from_bytes() within getUFT16String(). Solution is to append a UFT16 null char to the end of any string we try to do a conversion on that is not null terminated. --- rejistry++/src/RegistryByteBuffer.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/rejistry++/src/RegistryByteBuffer.cpp b/rejistry++/src/RegistryByteBuffer.cpp index c6175a9fe..1322ea0e7 100644 --- a/rejistry++/src/RegistryByteBuffer.cpp +++ b/rejistry++/src/RegistryByteBuffer.cpp @@ -127,12 +127,13 @@ namespace Rejistry { if (nullPos == 0) { return L""; } - // NULL Pointer not found + + // UFT16 NULL char not found so add it + // Non-ascii registry key names seem to not be NULL terminated + // which leads to conversion errors in from_bytes() (CT-2917) else if (nullPos == data.size()) { - // @@@ BC: I'm not sure if this is correct. But, we got exceptions if - // we kept it past the buffer. - // Are these always supposed to be NULL terminated, in which case this is an error? - nullPos = data.size() - 1; + data.push_back('\0'); + data.push_back('\0'); } std::wstring result; -- GitLab