[PATCH v2 1/3] webservices: Don't advance binary encoding reader if record type doesn't match.

Hans Leidekker hans at codeweavers.com
Wed Apr 20 04:56:10 CDT 2022


From: Connor McAdams <cmcadams at codeweavers.com>

Signed-off-by: Connor McAdams <cmcadams at codeweavers.com>
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
---
 dlls/webservices/reader.c       | 18 ++++++++++++------
 dlls/webservices/tests/reader.c | 15 ++++++---------
 2 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/dlls/webservices/reader.c b/dlls/webservices/reader.c
index 7da0c8335ea..b22bcbd51b1 100644
--- a/dlls/webservices/reader.c
+++ b/dlls/webservices/reader.c
@@ -1486,8 +1486,9 @@ static HRESULT read_attribute_value_bin( struct reader *reader, WS_XML_ATTRIBUTE
     GUID guid;
     HRESULT hr;
 
-    if ((hr = read_byte( reader, &type )) != S_OK) return hr;
+    if ((hr = read_peek( reader, &type, 1 )) != S_OK) return hr;
     if (!is_text_type( type )) return WS_E_INVALID_FORMAT;
+    read_skip( reader, 1 );
 
     switch (type)
     {
@@ -1771,9 +1772,10 @@ static HRESULT read_attribute_bin( struct reader *reader, WS_XML_ATTRIBUTE **ret
     unsigned char type = 0;
     HRESULT hr;
 
-    if ((hr = read_byte( reader, &type )) != S_OK) return hr;
+    if ((hr = read_peek( reader, &type, 1 )) != S_OK) return hr;
     if (!is_attribute_type( type )) return WS_E_INVALID_FORMAT;
     if (!(attr = calloc( 1, sizeof(*attr) ))) return E_OUTOFMEMORY;
+    read_skip( reader, 1 );
 
     if (type >= RECORD_PREFIX_ATTRIBUTE_A && type <= RECORD_PREFIX_ATTRIBUTE_Z)
     {
@@ -2068,8 +2070,9 @@ static HRESULT read_element_bin( struct reader *reader )
     unsigned char type;
     HRESULT hr;
 
-    if ((hr = read_byte( reader, &type )) != S_OK) return hr;
+    if ((hr = read_peek( reader, &type, 1 )) != S_OK) return hr;
     if (!is_element_type( type )) return WS_E_INVALID_FORMAT;
+    read_skip( reader, 1 );
 
     if (!(elem = alloc_element_pair())) return E_OUTOFMEMORY;
     node = (struct node *)elem;
@@ -2480,8 +2483,9 @@ static HRESULT read_text_bin( struct reader *reader )
     GUID uuid;
     HRESULT hr;
 
-    if ((hr = read_byte( reader, &type )) != S_OK) return hr;
+    if ((hr = read_peek( reader, &type, 1 )) != S_OK) return hr;
     if (!is_text_type( type ) || !(parent = find_parent( reader ))) return WS_E_INVALID_FORMAT;
+    read_skip( reader, 1 );
 
     switch (type)
     {
@@ -2835,8 +2839,9 @@ static HRESULT read_endelement_bin( struct reader *reader )
 
     if (!(reader->current->flags & NODE_FLAG_TEXT_WITH_IMPLICIT_END_ELEMENT))
     {
-        if ((hr = read_byte( reader, &type )) != S_OK) return hr;
+        if ((hr = read_peek( reader, &type, 1 )) != S_OK) return hr;
         if (type != RECORD_ENDELEMENT) return WS_E_INVALID_FORMAT;
+        read_skip( reader, 1 );
     }
     if (!(parent = find_parent( reader ))) return WS_E_INVALID_FORMAT;
 
@@ -2917,8 +2922,9 @@ static HRESULT read_comment_bin( struct reader *reader )
     ULONG len;
     HRESULT hr;
 
-    if ((hr = read_byte( reader, &type )) != S_OK) return hr;
+    if ((hr = read_peek( reader, &type, 1 )) != S_OK) return hr;
     if (type != RECORD_COMMENT) return WS_E_INVALID_FORMAT;
+    read_skip( reader, 1 );
     if ((hr = read_int31( reader, &len )) != S_OK) return hr;
 
     if (!(parent = find_parent( reader ))) return WS_E_INVALID_FORMAT;
diff --git a/dlls/webservices/tests/reader.c b/dlls/webservices/tests/reader.c
index 1a2cd1fe420..f62697b9662 100644
--- a/dlls/webservices/tests/reader.c
+++ b/dlls/webservices/tests/reader.c
@@ -5764,15 +5764,12 @@ static void test_binary_encoding(void)
 
     hr = WsReadType( reader, WS_ELEMENT_TYPE_MAPPING, WS_STRUCT_TYPE, &s,
                      WS_READ_REQUIRED_POINTER, heap, &test_struct, sizeof(test_struct), NULL );
-    todo_wine ok( hr == S_OK, "got %#lx\n", hr );
-    if (SUCCEEDED(hr))
-    {
-        ok( test_struct->a == 1, "got %d\n", test_struct->a );
-        ok( !!test_struct->s, "s is not set\n" );
-        ok( test_struct->s->s_a == 1, "got %d\n", test_struct->s->s_a );
-        ok( test_struct->s->s_b == 0, "got %d\n", test_struct->s->s_b );
-        ok( test_struct->b == 1, "got %d\n", test_struct->b );
-    }
+    ok( hr == S_OK, "got %#lx\n", hr );
+    ok( test_struct->a == 1, "got %d\n", test_struct->a );
+    ok( !!test_struct->s, "s is not set\n" );
+    ok( test_struct->s->s_a == 1, "got %d\n", test_struct->s->s_a );
+    ok( test_struct->s->s_b == 0, "got %d\n", test_struct->s->s_b );
+    ok( test_struct->b == 1, "got %d\n", test_struct->b );
 
     WsFreeHeap( heap );
     WsFreeReader( reader );
-- 
2.30.2




More information about the wine-devel mailing list