Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
dcfdfbaa
Commit
dcfdfbaa
authored
Aug 05, 2010
by
Andrew Eikum
Committed by
Alexandre Julliard
Aug 16, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
regedit: Improve importing of REG_SZ with invalid quoting.
parent
5e87ca77
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
94 additions
and
3 deletions
+94
-3
regproc.c
programs/regedit/regproc.c
+9
-3
regedit.c
programs/regedit/tests/regedit.c
+85
-0
No files found.
programs/regedit/regproc.c
View file @
dcfdfbaa
...
...
@@ -372,6 +372,8 @@ static LONG setValue(WCHAR* val_name, WCHAR* val_data, BOOL is_unicode)
* the extra garbage in the registry.
*/
dwLen
=
lstrlenW
(
val_data
);
if
(
val_data
[
dwLen
-
1
]
!=
'"'
)
return
ERROR_INVALID_DATA
;
if
(
dwLen
>
0
&&
val_data
[
dwLen
-
1
]
==
'"'
)
{
dwLen
--
;
...
...
@@ -497,7 +499,7 @@ static void processSetValue(WCHAR* line, BOOL is_unicode)
}
else
if
(
line
[
line_idx
]
==
'\"'
)
{
line_idx
++
;
val_name
=
line
+
line_idx
;
while
(
TRUE
)
{
while
(
line
[
line_idx
]
)
{
if
(
line
[
line_idx
]
==
'\\'
)
/* skip escaped character */
{
line_idx
+=
2
;
...
...
@@ -512,18 +514,22 @@ static void processSetValue(WCHAR* line, BOOL is_unicode)
}
}
while
(
isspaceW
(
line
[
line_idx
])
)
line_idx
++
;
if
(
!
line
[
line_idx
])
{
fprintf
(
stderr
,
"%s: warning: unexpected EOL
\n
"
,
getAppName
());
return
;
}
if
(
line
[
line_idx
]
!=
'='
)
{
char
*
lineA
;
line
[
line_idx
]
=
'\"'
;
lineA
=
GetMultiByteString
(
line
);
fprintf
(
stderr
,
"
Warning! unrecognized line:
\n
%s
\n
"
,
lineA
);
fprintf
(
stderr
,
"
%s: warning: unrecognized line: '%s'
\n
"
,
getAppName
()
,
lineA
);
HeapFree
(
GetProcessHeap
(),
0
,
lineA
);
return
;
}
}
else
{
char
*
lineA
=
GetMultiByteString
(
line
);
fprintf
(
stderr
,
"
Warning! unrecognized line:
\n
%s
\n
"
,
lineA
);
fprintf
(
stderr
,
"
%s: warning: unrecognized line: '%s'
\n
"
,
getAppName
()
,
lineA
);
HeapFree
(
GetProcessHeap
(),
0
,
lineA
);
return
;
}
...
...
programs/regedit/tests/regedit.c
View file @
dcfdfbaa
...
...
@@ -219,6 +219,28 @@ static void r_verify_reg_binary(unsigned line, HKEY key, const char *subkey,
"Data differs
\n
"
);
}
#define verify_reg_nonexist(k,s,n) r_verify_reg_nonexist(__LINE__,k,s,n)
static
void
r_verify_reg_nonexist
(
unsigned
line
,
HKEY
key
,
const
char
*
subkey
,
const
char
*
value_name
)
{
LONG
lr
;
DWORD
fnd_type
,
fnd_len
;
char
fnd_value
[
32
];
HKEY
fnd_key
;
lr
=
RegOpenKeyExA
(
key
,
subkey
,
0
,
KEY_READ
,
&
fnd_key
);
lok
(
lr
==
ERROR_SUCCESS
,
"RegOpenKeyExA failed: %d
\n
"
,
lr
);
if
(
lr
!=
ERROR_SUCCESS
)
return
;
fnd_len
=
sizeof
(
fnd_value
);
lr
=
RegQueryValueExA
(
fnd_key
,
value_name
,
NULL
,
&
fnd_type
,
(
BYTE
*
)
fnd_value
,
&
fnd_len
);
RegCloseKey
(
fnd_key
);
lok
(
lr
==
ERROR_FILE_NOT_FOUND
,
"Reg value shouldn't exist: %s
\n
"
,
value_name
);
}
static
void
test_basic_import
(
void
)
{
char
exp_binary
[]
=
{
0xAA
,
0xBB
,
0xCC
,
0x11
};
...
...
@@ -286,6 +308,68 @@ static void test_basic_import(void)
verify_reg_binary
(
HKEY_CURRENT_USER
,
"Software
\\
Wine
\\
regedit_test"
,
"TestBinary"
,
exp_binary
,
sizeof
(
exp_binary
));
exec_import_str
(
"REGEDIT4
\n\n
"
"[HKEY_CURRENT_USER
\\
Software
\\
Wine
\\
regedit_test]
\n
"
"
\"
With=Equals
\"
=
\"
asdf
\"\n
"
);
verify_reg_sz
(
HKEY_CURRENT_USER
,
"Software
\\
Wine
\\
regedit_test"
,
"With=Equals"
,
"asdf"
);
lr
=
RegDeleteKeyA
(
HKEY_CURRENT_USER
,
"Software
\\
Wine
\\
regedit_test"
);
ok
(
lr
==
ERROR_SUCCESS
,
"RegDeleteKeyA failed: %d
\n
"
,
lr
);
}
static
void
test_invalid_import
(
void
)
{
LONG
lr
;
lr
=
RegDeleteKeyA
(
HKEY_CURRENT_USER
,
"Software
\\
Wine
\\
regedit_test"
);
ok
(
lr
==
ERROR_SUCCESS
||
lr
==
ERROR_FILE_NOT_FOUND
,
"RegDeleteKeyA failed: %d
\n
"
,
lr
);
exec_import_str
(
"REGEDIT4
\n\n
"
"[HKEY_CURRENT_USER
\\
Software
\\
Wine
\\
regedit_test]
\n
"
"
\"
TestNoEndQuote
\"
=
\"
Asdffdsa
\n
"
);
verify_reg_nonexist
(
HKEY_CURRENT_USER
,
"Software
\\
Wine
\\
regedit_test"
,
"TestNoEndQuote"
);
exec_import_str
(
"REGEDIT4
\n\n
"
"[HKEY_CURRENT_USER
\\
Software
\\
Wine
\\
regedit_test]
\n
"
"
\"
TestNoBeginQuote
\"
=Asdffdsa
\"\n
"
);
verify_reg_nonexist
(
HKEY_CURRENT_USER
,
"Software
\\
Wine
\\
regedit_test"
,
"TestNoBeginQuote"
);
exec_import_str
(
"REGEDIT4
\n\n
"
"[HKEY_CURRENT_USER
\\
Software
\\
Wine
\\
regedit_test]
\n
"
"
\"
TestNoQuotes
\"
=Asdffdsa
\n
"
);
verify_reg_nonexist
(
HKEY_CURRENT_USER
,
"Software
\\
Wine
\\
regedit_test"
,
"TestNoQuotes"
);
exec_import_str
(
"REGEDIT4
\n\n
"
"[HKEY_CURRENT_USER
\\
Software
\\
Wine
\\
regedit_test]
\n
"
"
\"
NameNoEndQuote=
\"
Asdffdsa
\"\n
"
);
verify_reg_nonexist
(
HKEY_CURRENT_USER
,
"Software
\\
Wine
\\
regedit_test"
,
"NameNoEndQuote"
);
exec_import_str
(
"REGEDIT4
\n\n
"
"[HKEY_CURRENT_USER
\\
Software
\\
Wine
\\
regedit_test]
\n
"
"NameNoBeginQuote
\"
=
\"
Asdffdsa
\"\n
"
);
verify_reg_nonexist
(
HKEY_CURRENT_USER
,
"Software
\\
Wine
\\
regedit_test"
,
"NameNoBeginQuote"
);
exec_import_str
(
"REGEDIT4
\n\n
"
"[HKEY_CURRENT_USER
\\
Software
\\
Wine
\\
regedit_test]
\n
"
"NameNoQuotes=
\"
Asdffdsa
\"\n
"
);
verify_reg_nonexist
(
HKEY_CURRENT_USER
,
"Software
\\
Wine
\\
regedit_test"
,
"NameNoQuotes"
);
exec_import_str
(
"REGEDIT4
\n\n
"
"[HKEY_CURRENT_USER
\\
Software
\\
Wine
\\
regedit_test]
\n
"
"
\"
MixedQuotes=Asdffdsa
\"\n
"
);
verify_reg_nonexist
(
HKEY_CURRENT_USER
,
"Software
\\
Wine
\\
regedit_test"
,
"MixedQuotes"
);
verify_reg_nonexist
(
HKEY_CURRENT_USER
,
"Software
\\
Wine
\\
regedit_test"
,
"MixedQuotes=Asdffdsa"
);
lr
=
RegDeleteKeyA
(
HKEY_CURRENT_USER
,
"Software
\\
Wine
\\
regedit_test"
);
ok
(
lr
==
ERROR_SUCCESS
,
"RegDeleteKeyA failed: %d
\n
"
,
lr
);
}
...
...
@@ -304,4 +388,5 @@ START_TEST(regedit)
supports_wchar
=
exec_import_wstr
(
wchar_test
);
test_basic_import
();
test_invalid_import
();
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment