From 513505d6c4892bc276a5c2e780bf0f6cc2051416 Mon Sep 17 00:00:00 2001 From: Jonathan Vollebregt Date: Thu, 19 Feb 2015 13:19:11 +0100 Subject: [PATCH] reg: Add a check for multiple backslashes at the end of the key. --- programs/reg/reg.c | 8 ++++++++ programs/reg/tests/reg.c | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/programs/reg/reg.c b/programs/reg/reg.c index ffcbd4ad85..0fd579c9d9 100644 --- a/programs/reg/reg.c +++ b/programs/reg/reg.c @@ -181,6 +181,14 @@ static LPBYTE get_regdata(LPWSTR data, DWORD reg_type, WCHAR separator, DWORD *r static BOOL sane_path(const WCHAR *key) { + unsigned int i = strlenW(key); + + if (i < 3 || (key[i - 1] == '\\' && key[i - 2] == '\\')) + { + reg_message(STRING_INVALID_KEY); + return FALSE; + } + if (key[0] == '\\' && key[1] == '\\' && key[2] != '\\') { reg_message(STRING_NO_REMOTE); diff --git a/programs/reg/tests/reg.c b/programs/reg/tests/reg.c index b7605e4764..dbfce89544 100644 --- a/programs/reg/tests/reg.c +++ b/programs/reg/tests/reg.c @@ -129,10 +129,10 @@ static void test_add(void) ok(err == ERROR_FILE_NOT_FOUND, "got exit code %d\n", r); run_reg_exe("reg add HKCU\\" KEY_BASE "\\keytest2\\\\ /f", &r); - todo_wine ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), + ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %u\n", r); err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE "\\keytest2"); - todo_wine ok(err == ERROR_FILE_NOT_FOUND || broken(err == ERROR_SUCCESS /* WinXP */), + ok(err == ERROR_FILE_NOT_FOUND || broken(err == ERROR_SUCCESS /* WinXP */), "got exit code %d\n", r); run_reg_exe("reg add HKCU\\" KEY_BASE "\\keytest3\\ /f", &r);