Hugh McMaster : regedit: Accept various forms of "REGEDIT" with trailing characters.

Alexandre Julliard julliard at winehq.org
Wed Mar 22 15:52:35 CDT 2017


Module: wine
Branch: master
Commit: 0a7ff8aff7dec3d955a83f5ab8d37866086cab3d
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=0a7ff8aff7dec3d955a83f5ab8d37866086cab3d

Author: Hugh McMaster <hugh.mcmaster at outlook.com>
Date:   Wed Mar 22 11:54:28 2017 +0000

regedit: Accept various forms of "REGEDIT" with trailing characters.

Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 programs/regedit/regproc.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/programs/regedit/regproc.c b/programs/regedit/regproc.c
index 24c1e35..066fb2d 100644
--- a/programs/regedit/regproc.c
+++ b/programs/regedit/regproc.c
@@ -650,6 +650,7 @@ enum reg_versions {
     REG_VERSION_31,
     REG_VERSION_40,
     REG_VERSION_50,
+    REG_VERSION_FUZZY,
     REG_VERSION_INVALID
 };
 
@@ -672,6 +673,14 @@ static enum reg_versions parse_file_header(WCHAR *s)
     if (!strcmpW(s, header_50))
         return REG_VERSION_50;
 
+    /* The Windows version accepts registry file headers beginning with "REGEDIT" and ending
+     * with other characters, as long as "REGEDIT" appears at the start of the line. For example,
+     * "REGEDIT 4", "REGEDIT9" and "REGEDIT4FOO" are all treated as valid file headers.
+     * In all such cases, however, the contents of the registry file are not imported.
+     */
+    if (!strncmpW(s, header_31, 7)) /* "REGEDIT" without NUL */
+        return REG_VERSION_FUZZY;
+
     return REG_VERSION_INVALID;
 }
 
@@ -763,10 +772,10 @@ static BOOL processRegLinesA(FILE *fp, char *two_chars)
 
     reg_version = parse_file_header(lineW);
     HeapFree(GetProcessHeap(), 0, lineW);
-    if (reg_version == REG_VERSION_INVALID)
+    if (reg_version == REG_VERSION_FUZZY || reg_version == REG_VERSION_INVALID)
     {
         get_lineA(NULL); /* Reset static variables */
-        return FALSE;
+        return reg_version == REG_VERSION_FUZZY;
     }
 
     while ((line = get_lineA(fp)))
@@ -863,10 +872,10 @@ static BOOL processRegLinesW(FILE *fp)
 
     line = get_lineW(fp);
     reg_version = parse_file_header(line);
-    if (reg_version == REG_VERSION_INVALID)
+    if (reg_version == REG_VERSION_FUZZY || reg_version == REG_VERSION_INVALID)
     {
         get_lineW(NULL); /* Reset static variables */
-        return FALSE;
+        return reg_version == REG_VERSION_FUZZY;
     }
 
     while ((line = get_lineW(fp)))




More information about the wine-cvs mailing list