[PATCH 0/2] MR1023: xmllite/writer: Correctly partially duplicate a string
Currently, the code seems to copy an extra character than requested and does not terminate the string Signed-off-by: David Kahurani <k.kahurani(a)gmail.com> -- https://gitlab.winehq.org/wine/wine/-/merge_requests/1023
From: David Kahurani <k.kahurani(a)gmail.com> Current code skips a character and goes on to run is_namechar the next instead of the current character ultimately always running a null string on is_namechar and therefore always returning error on multi-character strings Signed-off-by: David Kahurani <k.kahurani(a)gmail.com> --- dlls/xmllite/tests/writer.c | 8 ++++++++ dlls/xmllite/writer.c | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/dlls/xmllite/tests/writer.c b/dlls/xmllite/tests/writer.c index 7b98f61a207..c4ab079373c 100644 --- a/dlls/xmllite/tests/writer.c +++ b/dlls/xmllite/tests/writer.c @@ -2145,6 +2145,14 @@ static void test_WriteDocType(void) hr = IXmlWriter_WriteDocType(writer, L"a", pubidW, NULL, NULL); ok(hr == WC_E_PUBLICID, "Unexpected hr %#lx.\n", hr); + /* Invalid multi-character string */ + hr = IXmlWriter_WriteDocType(writer, L":ax>m", NULL, NULL, NULL); + ok(hr == WC_E_NAMECHARACTER, "Unexpected hr %#lx.\n", hr); + + /* Valid multi-character string */ + hr = IXmlWriter_WriteDocType(writer, L"root", NULL, NULL, NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + IStream_Release(stream); for (i = 0; i < ARRAY_SIZE(doctype_tests); i++) diff --git a/dlls/xmllite/writer.c b/dlls/xmllite/writer.c index 1e1a8e8ddb8..c4f9ed2f440 100644 --- a/dlls/xmllite/writer.c +++ b/dlls/xmllite/writer.c @@ -376,11 +376,12 @@ static HRESULT is_valid_name(const WCHAR *str, unsigned int *out) if (!is_namestartchar(*str++)) return WC_E_NAMECHARACTER; - while (*str++) + while (*str) { if (!is_namechar(*str)) return WC_E_NAMECHARACTER; len++; + str++; } *out = len; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/1023
From: David Kahurani <k.kahurani(a)gmail.com> Signed-off-by: David Kahurani <k.kahurani(a)gmail.com> --- dlls/xmllite/writer.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/dlls/xmllite/writer.c b/dlls/xmllite/writer.c index c4f9ed2f440..015aa2a6ecf 100644 --- a/dlls/xmllite/writer.c +++ b/dlls/xmllite/writer.c @@ -250,7 +250,6 @@ static struct element *pop_element(xmlwriter *writer) static WCHAR *writer_strndupW(const xmlwriter *writer, const WCHAR *str, int len) { - size_t size; WCHAR *ret; if (!str) @@ -259,9 +258,12 @@ static WCHAR *writer_strndupW(const xmlwriter *writer, const WCHAR *str, int len if (len == -1) len = lstrlenW(str); - size = (len + 1) * sizeof(WCHAR); - ret = writer_alloc(writer, size); - if (ret) memcpy(ret, str, size); + ret = writer_alloc(writer, (len + 1 ) * sizeof(WCHAR)); + if (ret) + { + memcpy(ret, str, len * sizeof(WCHAR)); + ret[len] = 0; + } return ret; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/1023
Hi, It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated. The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details: The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=124837 Your paranoid android. === debian11 (32 bit report) === d3d8: device: Timeout
This merge request was closed by David Kahurani. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/1023
Sorry for the noise, deleted this one as there was a commit already in another MR. Maybe I could have just force pushed? Didn't think about that until a few minutes later... -- https://gitlab.winehq.org/wine/wine/-/merge_requests/1023#note_10115
Yes, next time just push to the same branch. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/1023#note_10117
participants (4)
-
David Kahurani -
David Kahurani (@kahurani) -
Marvin -
Nikolay Sivov (@nsivov)