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

Alexandre Julliard julliard at winehq.org
Thu Sep 17 15:51:09 CDT 2020


Module: wine
Branch: master
Commit: 5b7fac05d95fd2cd0c274f1342fb96d0f7152848
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=5b7fac05d95fd2cd0c274f1342fb96d0f7152848

Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date:   Thu Sep 17 12:16:35 2020 +0300

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

Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/setupapi/parser.c       | 4 ++--
 dlls/setupapi/tests/parser.c | 7 +++++--
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/dlls/setupapi/parser.c b/dlls/setupapi/parser.c
index 560c2401b8..c81a712ad8 100644
--- a/dlls/setupapi/parser.c
+++ b/dlls/setupapi/parser.c
@@ -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;
diff --git a/dlls/setupapi/tests/parser.c b/dlls/setupapi/tests/parser.c
index 8cde35b9de..c18063fbe3 100644
--- a/dlls/setupapi/tests/parser.c
+++ b/dlls/setupapi/tests/parser.c
@@ -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",




More information about the wine-cvs mailing list