Skip to content

Commit

Permalink
fixup: skip only 18 WCHAR if keyName begins with \\registry\\machine
Browse files Browse the repository at this point in the history
Note that keyName was declared char * in the original code.
But now it is WCHAR*, so keyName+18 already does the right thing (skip 18 char) while modified code would now skip 36!
Note that original code was using memcpy for this case of overlapping memory which is BAD and eventually UB.
[skip travis]
  • Loading branch information
nicolas-cellier-aka-nice committed Jan 2, 2019
1 parent 252e2a8 commit 3e51616
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion platforms/win32/vm/sqWin32Main.c
Expand Up @@ -732,7 +732,7 @@ void gatherSystemInfo(void) {
I have no idea why but for now I'll just truncate that part if
we recognize it... */
if (_wcsnicmp(keyName, L"\\registry\\machine\\", 18) == 0) {
memmove(keyName, keyName+18*sizeof(WCHAR), (wcslen(keyName)-17)*sizeof(WCHAR));
memmove(keyName, keyName+18, (wcslen(keyName)+1-18)*sizeof(WCHAR)); /* +1 for terminating NULL */
}

ok = RegOpenKeyW(HKEY_LOCAL_MACHINE, keyName, &hk);
Expand Down

0 comments on commit 3e51616

Please sign in to comment.