From 064edd2d8b3f02b57fd881d40e89cf7ae9c1adba Mon Sep 17 00:00:00 2001 From: Akihiro Sagawa Date: Mon, 10 Oct 2016 22:53:12 +0900 Subject: [PATCH] webservices: Avoid decoding a nul character reference. Signed-off-by: Akihiro Sagawa Signed-off-by: Hans Leidekker Signed-off-by: Alexandre Julliard --- dlls/webservices/reader.c | 2 ++ dlls/webservices/tests/reader.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/dlls/webservices/reader.c b/dlls/webservices/reader.c index 8b9faf29039..655288a5ab7 100644 --- a/dlls/webservices/reader.c +++ b/dlls/webservices/reader.c @@ -1166,6 +1166,8 @@ static HRESULT parse_name( const unsigned char *str, unsigned int len, static int codepoint_to_utf8( int cp, unsigned char *dst ) { + if (!cp) + return -1; if (cp < 0x80) { *dst = cp; diff --git a/dlls/webservices/tests/reader.c b/dlls/webservices/tests/reader.c index 06c18b24d28..76de14a3447 100644 --- a/dlls/webservices/tests/reader.c +++ b/dlls/webservices/tests/reader.c @@ -3610,6 +3610,7 @@ static void test_entities(void) static const char str25[] = ""; static const char str26[] = "￿"; static const char str27[] = "<"; + static const char str28[] = ""; static const char res4[] = {0xea, 0xaa, 0xaa, 0x00}; static const char res5[] = {0xf2, 0xaa, 0xaa, 0xaa, 0x00}; static const char res21[] = {0xed, 0x9f, 0xbf, 0x00}; @@ -3649,6 +3650,7 @@ static void test_entities(void) { str25, WS_E_INVALID_FORMAT }, { str26, WS_E_INVALID_FORMAT }, { str27, WS_E_INVALID_FORMAT }, + { str28, WS_E_INVALID_FORMAT }, }; HRESULT hr; WS_XML_READER *reader;