[PATCH 03/13] reg: Validate the system key before commencing the export operation
Signed-off-by: Hugh McMaster <hugh.mcmaster(a)outlook.com> --- programs/reg/export.c | 6 ++++++ programs/reg/reg.c | 2 +- programs/reg/reg.h | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/programs/reg/export.c b/programs/reg/export.c index 530d11b707..720b9ef703 100644 --- a/programs/reg/export.c +++ b/programs/reg/export.c @@ -38,9 +38,15 @@ static BOOL is_overwrite_switch(const WCHAR *s) int reg_export(int argc, WCHAR *argv[]) { + HKEY root; + WCHAR *path, *long_key; + if (argc == 3 || argc > 5) goto error; + if (!parse_registry_key(argv[2], &root, &path, &long_key)) + return 1; + if (argc == 5 && !is_overwrite_switch(argv[4])) goto error; diff --git a/programs/reg/reg.c b/programs/reg/reg.c index 7affdd282b..a65bfc8d05 100644 --- a/programs/reg/reg.c +++ b/programs/reg/reg.c @@ -873,7 +873,7 @@ static WCHAR *get_long_key(HKEY root, WCHAR *path) return long_key; } -static BOOL parse_registry_key(const WCHAR *key, HKEY *root, WCHAR **path, WCHAR **long_key) +BOOL parse_registry_key(const WCHAR *key, HKEY *root, WCHAR **path, WCHAR **long_key) { if (!sane_path(key)) return FALSE; diff --git a/programs/reg/reg.h b/programs/reg/reg.h index b4751e408c..3b5ab86ff9 100644 --- a/programs/reg/reg.h +++ b/programs/reg/reg.h @@ -29,6 +29,7 @@ void *heap_xrealloc(void *buf, size_t size); BOOL heap_free(void *buf); void WINAPIV output_message(unsigned int id, ...); HKEY path_get_rootkey(const WCHAR *path); +BOOL parse_registry_key(const WCHAR *key, HKEY *root, WCHAR **path, WCHAR **long_key); /* import.c */ int reg_import(const WCHAR *filename); -- 2.15.0
participants (1)
-
Hugh McMaster