setupapi: Treat trailing \0 in field values same way as trailing spaces.

Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Dmitry Timoshkov 2020-09-17 12:16:35 +03:00 committed by Alexandre Julliard
parent 43115a74f9
commit 5b7fac05d9
2 changed files with 7 additions and 4 deletions

View file

@ -724,7 +724,7 @@ static const WCHAR *value_name_state( struct parser *parser, const WCHAR *pos )
set_state( parser, EOL_BACKSLASH );
return p;
default:
if (!iswspace(*p)) token_end = p + 1;
if (*p && !iswspace(*p)) token_end = p + 1;
else
{
push_token( parser, p );
@ -838,7 +838,7 @@ static const WCHAR *trailing_spaces_state( struct parser *parser, const WCHAR *p
set_state( parser, EOL_BACKSLASH );
return p;
}
if (!iswspace(*p)) break;
if (*p && !iswspace(*p)) break;
}
pop_state( parser );
return p;

View file

@ -370,6 +370,9 @@ static const struct
{ C("ab\032=cd"), "ab", { "ab" } },
/* nulls */
{ C("abcd=ef\x0gh"), "abcd", { "ef gh" } },
{ C("foo=%bar%\n[Strings]\nbar=bbb\0\n"), "foo", { "bbb" } },
{ C("foo=%bar%\n[Strings]\nbar=bbb \0\n"), "foo", { "bbb" } },
{ C("foo=%bar%\n[Strings]\nbar=aaa\0bbb \0\n"), "foo", { "aaa bbb" } },
/* multiple sections with same name */
{ C("[Test2]\nab\n[Test]\nee=ff\n"), "ee", { "ff" } },
/* string substitution */
@ -470,12 +473,12 @@ static void test_key_names(void)
ok( err == 0, "line %u: bad error %u\n", i, err );
if (key_names[i].fields[index])
{
if (i == 49)
if (i == 52)
ok( !strcmp( field, key_names[i].fields[index] ) ||
!strcmp( field, A1200), /* Vista, W2K8 */
"line %u: bad field %s/%s\n",
i, field, key_names[i].fields[index] );
else if (i == 52)
else if (i == 55)
ok( !strcmp( field, key_names[i].fields[index] ) ||
!strcmp( field, A4096), /* Win10 >= 1709 */
"line %u: bad field %s/%s\n",