mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2024-09-13 09:17:20 -07:00
Added dnsapi_dns_records patchset
This commit is contained in:
parent
e9b0c33d65
commit
6c167535e3
@ -0,0 +1,96 @@
|
||||
From fcf816014b4f7ce60b544f5a50a5a88ade3b055b Mon Sep 17 00:00:00 2001
|
||||
From: Dmitry Timoshkov <dmitry@baikal.ru>
|
||||
Date: Thu, 1 Jun 2023 14:30:10 +0300
|
||||
Subject: [PATCH] dnsapi/tests: Add some tests for DNS_TYPE_SRV messages.
|
||||
|
||||
Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru>
|
||||
---
|
||||
dlls/dnsapi/tests/record.c | 65 ++++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 65 insertions(+)
|
||||
|
||||
diff --git a/dlls/dnsapi/tests/record.c b/dlls/dnsapi/tests/record.c
|
||||
index 20738de3618..8abcdadaacc 100644
|
||||
--- a/dlls/dnsapi/tests/record.c
|
||||
+++ b/dlls/dnsapi/tests/record.c
|
||||
@@ -193,6 +193,28 @@ static BYTE msg_types[] = /* various record types */
|
||||
/* KEY */ 0xc0, 0x0c, 0x00, 0x19, 0x00, 0x01, 0x04, 0x05, 0x06, 0x07, 0x00, 0x06, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66,
|
||||
/* TXT */ 0x01, 't', 0x01, 'x', 0x00, 0x00, 0x10, 0x00, 0x01, 0x04, 0x05, 0x06, 0x07, 0x00, 0x09, 0x02, 'z', 'y', 0x00, 0x04, 'X', 'Y', 0xc3, 0xa9
|
||||
};
|
||||
+static BYTE msg_question_srv[] = /* SRV question only */
|
||||
+{
|
||||
+ 0x12, 0x34, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
+ 5,'_','l','d','a','p',4,'_','t','c','p',2,'d','c',6,'_','m','s','d','c','s',6,'w','i','n','e','h','q',3,'o','r','g',0x00,0x00,0x00,0x21,0x00
|
||||
+};
|
||||
+static BYTE msg_answer_srv[] = /* SRV answer only */
|
||||
+{
|
||||
+ 0x12, 0x34, 0x81, 0x80, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
+ 5,'_','l','d','a','p',4,'_','t','c','p',2,'d','c',6,'_','m','s','d','c','s',6,'w','i','n','e','h','q',3,'o','r','g',0x00,
|
||||
+ 0x00,0x21,0x00,0x01,0x04,0x05,0x06,0x07,
|
||||
+ 0x00,0x15,0x00,0x00,0x00,0x00,0x01,0x85,
|
||||
+ 2,'d','c',6,'w','i','n','e','h','q',3,'o','r','g',0x00
|
||||
+};
|
||||
+static BYTE msg_full_srv[] = /* SRV question + answer */
|
||||
+{
|
||||
+ 0x12, 0x34, 0x81, 0x80, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
+ 5,'_','l','d','a','p',4,'_','t','c','p',2,'d','c',6,'_','m','s','d','c','s',6,'w','i','n','e','h','q',3,'o','r','g',0x00,
|
||||
+ 0x00,0x21,0x00,0x01,
|
||||
+ 0xc0,0x0c,0x00,0x21,0x00,0x01,0x04,0x05,0x06,0x07,
|
||||
+ 0x00,0x15,0x00,0x00,0x00,0x00,0x01,0x85,
|
||||
+ 2,'d','c',6,'w','i','n','e','h','q',3,'o','r','g',0x00
|
||||
+};
|
||||
|
||||
static void test_DnsExtractRecordsFromMessage(void)
|
||||
{
|
||||
@@ -200,6 +222,49 @@ static void test_DnsExtractRecordsFromMessage(void)
|
||||
DNS_RECORDA *rec, *r;
|
||||
DNS_RECORDW *recW, *rW;
|
||||
|
||||
+ rec = NULL;
|
||||
+ ret = DnsExtractRecordsFromMessage_UTF8( (DNS_MESSAGE_BUFFER *)msg_full_srv, sizeof(msg_full_srv), &rec );
|
||||
+ todo_wine
|
||||
+ ok( !ret, "failed %ld\n", ret );
|
||||
+ todo_wine
|
||||
+ ok( rec != NULL, "record not set\n" );
|
||||
+ if (!rec) goto next;
|
||||
+ ok( !strcmp( rec->pName, "_ldap._tcp.dc._msdcs.winehq.org" ), "wrong name %s\n", rec->pName );
|
||||
+ ok( rec->Flags.S.Section == DnsSectionAnswer, "wrong section %u\n", rec->Flags.S.Section );
|
||||
+ ok( rec->Flags.S.CharSet == DnsCharSetUtf8, "wrong charset %u\n", rec->Flags.S.CharSet );
|
||||
+ ok( rec->wType == DNS_TYPE_SRV, "wrong type %u\n", rec->wType );
|
||||
+ todo_wine
|
||||
+ ok( rec->wDataLength == sizeof(DNS_SRV_DATAA) + strlen( "dc.winehq.org" ) + 1, "wrong len %u\n", rec->wDataLength );
|
||||
+ ok( rec->dwTtl == 0x04050607, "wrong ttl %#lx\n", rec->dwTtl );
|
||||
+ ok( !strcmp( rec->Data.SRV.pNameTarget, "dc.winehq.org"), "wrong target %s\n", rec->Data.SRV.pNameTarget );
|
||||
+ ok( !rec->pNext, "next record %p\n", rec->pNext );
|
||||
+ DnsRecordListFree( (DNS_RECORD *)rec, DnsFreeRecordList );
|
||||
+
|
||||
+next:
|
||||
+ rec = (void *)0xdeadbeef;
|
||||
+ ret = DnsExtractRecordsFromMessage_UTF8( (DNS_MESSAGE_BUFFER *)msg_question_srv, sizeof(msg_question_srv), &rec );
|
||||
+ ok( !ret, "failed %ld\n", ret );
|
||||
+ ok( !rec, "record %p\n", rec );
|
||||
+
|
||||
+ rec = NULL;
|
||||
+ ret = DnsExtractRecordsFromMessage_UTF8( (DNS_MESSAGE_BUFFER *)msg_answer_srv, sizeof(msg_answer_srv), &rec );
|
||||
+ todo_wine
|
||||
+ ok( !ret, "failed %ld\n", ret );
|
||||
+ todo_wine
|
||||
+ ok( rec != NULL, "record not set\n" );
|
||||
+ if (!rec) goto next2;
|
||||
+ ok( !strcmp( rec->pName, "_ldap._tcp.dc._msdcs.winehq.org" ), "wrong name %s\n", rec->pName );
|
||||
+ ok( rec->Flags.S.Section == DnsSectionAnswer, "wrong section %u\n", rec->Flags.S.Section );
|
||||
+ ok( rec->Flags.S.CharSet == DnsCharSetUtf8, "wrong charset %u\n", rec->Flags.S.CharSet );
|
||||
+ ok( rec->wType == DNS_TYPE_SRV, "wrong type %u\n", rec->wType );
|
||||
+ todo_wine
|
||||
+ ok( rec->wDataLength == sizeof(DNS_SRV_DATAA) + strlen( "dc.winehq.org" ) + 1, "wrong len %u\n", rec->wDataLength );
|
||||
+ ok( rec->dwTtl == 0x04050607, "wrong ttl %#lx\n", rec->dwTtl );
|
||||
+ ok( !strcmp( rec->Data.SRV.pNameTarget, "dc.winehq.org"), "wrong target %s\n", rec->Data.SRV.pNameTarget );
|
||||
+ ok( !rec->pNext, "next record %p\n", rec->pNext );
|
||||
+ DnsRecordListFree( (DNS_RECORD *)rec, DnsFreeRecordList );
|
||||
+
|
||||
+next2:
|
||||
ret = DnsExtractRecordsFromMessage_UTF8( (DNS_MESSAGE_BUFFER *)msg_empty, sizeof(msg_empty) - 1, &rec );
|
||||
ok( ret == ERROR_INVALID_PARAMETER || broken(ret == DNS_ERROR_BAD_PACKET) /* win7 */,
|
||||
"failed %ld\n", ret );
|
||||
--
|
||||
2.40.1
|
||||
|
@ -0,0 +1,72 @@
|
||||
From 3c5ac02e18d5898d68c01f6a58996dc47e5582db Mon Sep 17 00:00:00 2001
|
||||
From: Dmitry Timoshkov <dmitry@baikal.ru>
|
||||
Date: Thu, 1 Jun 2023 14:32:55 +0300
|
||||
Subject: [PATCH] dnsapi: Accept name records of exact size at the end of the
|
||||
packet.
|
||||
|
||||
Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru>
|
||||
---
|
||||
dlls/dnsapi/record.c | 2 +-
|
||||
dlls/dnsapi/tests/record.c | 8 --------
|
||||
2 files changed, 1 insertion(+), 9 deletions(-)
|
||||
|
||||
diff --git a/dlls/dnsapi/record.c b/dlls/dnsapi/record.c
|
||||
index 01786842b73..cfd55a44852 100644
|
||||
--- a/dlls/dnsapi/record.c
|
||||
+++ b/dlls/dnsapi/record.c
|
||||
@@ -199,7 +199,7 @@ static const BYTE *get_name( const BYTE *base, const BYTE *end, const BYTE *ptr,
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
- if (ptr >= end) return NULL;
|
||||
+ if (ptr > end) return NULL;
|
||||
if (out == name) *out++ = '.';
|
||||
*out = 0;
|
||||
return next ? next : ptr;
|
||||
diff --git a/dlls/dnsapi/tests/record.c b/dlls/dnsapi/tests/record.c
|
||||
index 8abcdadaacc..340d10f6024 100644
|
||||
--- a/dlls/dnsapi/tests/record.c
|
||||
+++ b/dlls/dnsapi/tests/record.c
|
||||
@@ -224,11 +224,8 @@ static void test_DnsExtractRecordsFromMessage(void)
|
||||
|
||||
rec = NULL;
|
||||
ret = DnsExtractRecordsFromMessage_UTF8( (DNS_MESSAGE_BUFFER *)msg_full_srv, sizeof(msg_full_srv), &rec );
|
||||
- todo_wine
|
||||
ok( !ret, "failed %ld\n", ret );
|
||||
- todo_wine
|
||||
ok( rec != NULL, "record not set\n" );
|
||||
- if (!rec) goto next;
|
||||
ok( !strcmp( rec->pName, "_ldap._tcp.dc._msdcs.winehq.org" ), "wrong name %s\n", rec->pName );
|
||||
ok( rec->Flags.S.Section == DnsSectionAnswer, "wrong section %u\n", rec->Flags.S.Section );
|
||||
ok( rec->Flags.S.CharSet == DnsCharSetUtf8, "wrong charset %u\n", rec->Flags.S.CharSet );
|
||||
@@ -240,7 +237,6 @@ static void test_DnsExtractRecordsFromMessage(void)
|
||||
ok( !rec->pNext, "next record %p\n", rec->pNext );
|
||||
DnsRecordListFree( (DNS_RECORD *)rec, DnsFreeRecordList );
|
||||
|
||||
-next:
|
||||
rec = (void *)0xdeadbeef;
|
||||
ret = DnsExtractRecordsFromMessage_UTF8( (DNS_MESSAGE_BUFFER *)msg_question_srv, sizeof(msg_question_srv), &rec );
|
||||
ok( !ret, "failed %ld\n", ret );
|
||||
@@ -248,11 +244,8 @@ next:
|
||||
|
||||
rec = NULL;
|
||||
ret = DnsExtractRecordsFromMessage_UTF8( (DNS_MESSAGE_BUFFER *)msg_answer_srv, sizeof(msg_answer_srv), &rec );
|
||||
- todo_wine
|
||||
ok( !ret, "failed %ld\n", ret );
|
||||
- todo_wine
|
||||
ok( rec != NULL, "record not set\n" );
|
||||
- if (!rec) goto next2;
|
||||
ok( !strcmp( rec->pName, "_ldap._tcp.dc._msdcs.winehq.org" ), "wrong name %s\n", rec->pName );
|
||||
ok( rec->Flags.S.Section == DnsSectionAnswer, "wrong section %u\n", rec->Flags.S.Section );
|
||||
ok( rec->Flags.S.CharSet == DnsCharSetUtf8, "wrong charset %u\n", rec->Flags.S.CharSet );
|
||||
@@ -264,7 +257,6 @@ next:
|
||||
ok( !rec->pNext, "next record %p\n", rec->pNext );
|
||||
DnsRecordListFree( (DNS_RECORD *)rec, DnsFreeRecordList );
|
||||
|
||||
-next2:
|
||||
ret = DnsExtractRecordsFromMessage_UTF8( (DNS_MESSAGE_BUFFER *)msg_empty, sizeof(msg_empty) - 1, &rec );
|
||||
ok( ret == ERROR_INVALID_PARAMETER || broken(ret == DNS_ERROR_BAD_PACKET) /* win7 */,
|
||||
"failed %ld\n", ret );
|
||||
--
|
||||
2.40.1
|
||||
|
@ -0,0 +1,49 @@
|
||||
From 623038324e863d3438243f75f5726291e5ee3ac2 Mon Sep 17 00:00:00 2001
|
||||
From: Dmitry Timoshkov <dmitry@baikal.ru>
|
||||
Date: Thu, 1 Jun 2023 14:48:23 +0300
|
||||
Subject: [PATCH] dnsapi: Set correct wDataLength for DNS_TYPE_SRV records.
|
||||
|
||||
Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru>
|
||||
---
|
||||
dlls/dnsapi/record.c | 4 ++++
|
||||
dlls/dnsapi/tests/record.c | 2 --
|
||||
2 files changed, 4 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/dlls/dnsapi/record.c b/dlls/dnsapi/record.c
|
||||
index cfd55a44852..1b4cbfeac0f 100644
|
||||
--- a/dlls/dnsapi/record.c
|
||||
+++ b/dlls/dnsapi/record.c
|
||||
@@ -1046,6 +1046,10 @@ static DNS_STATUS extract_rdata( const BYTE *base, const BYTE *end, const BYTE *
|
||||
if (!get_name( base, end, pos, name )) return DNS_ERROR_BAD_PACKET;
|
||||
if (!(r->Data.SRV.pNameTarget = strdupX( name, in, out ))) return ERROR_NOT_ENOUGH_MEMORY;
|
||||
r->wDataLength = sizeof(DNS_SRV_DATAA);
|
||||
+ if (out == DnsCharSetUnicode)
|
||||
+ r->wDataLength += (wcslen( (const WCHAR *)r->Data.SRV.pNameTarget ) + 1) * sizeof(WCHAR);
|
||||
+ else
|
||||
+ r->wDataLength += strlen( r->Data.SRV.pNameTarget ) + 1;
|
||||
break;
|
||||
|
||||
case DNS_TYPE_HINFO:
|
||||
diff --git a/dlls/dnsapi/tests/record.c b/dlls/dnsapi/tests/record.c
|
||||
index 340d10f6024..d340c064554 100644
|
||||
--- a/dlls/dnsapi/tests/record.c
|
||||
+++ b/dlls/dnsapi/tests/record.c
|
||||
@@ -230,7 +230,6 @@ static void test_DnsExtractRecordsFromMessage(void)
|
||||
ok( rec->Flags.S.Section == DnsSectionAnswer, "wrong section %u\n", rec->Flags.S.Section );
|
||||
ok( rec->Flags.S.CharSet == DnsCharSetUtf8, "wrong charset %u\n", rec->Flags.S.CharSet );
|
||||
ok( rec->wType == DNS_TYPE_SRV, "wrong type %u\n", rec->wType );
|
||||
- todo_wine
|
||||
ok( rec->wDataLength == sizeof(DNS_SRV_DATAA) + strlen( "dc.winehq.org" ) + 1, "wrong len %u\n", rec->wDataLength );
|
||||
ok( rec->dwTtl == 0x04050607, "wrong ttl %#lx\n", rec->dwTtl );
|
||||
ok( !strcmp( rec->Data.SRV.pNameTarget, "dc.winehq.org"), "wrong target %s\n", rec->Data.SRV.pNameTarget );
|
||||
@@ -250,7 +249,6 @@ static void test_DnsExtractRecordsFromMessage(void)
|
||||
ok( rec->Flags.S.Section == DnsSectionAnswer, "wrong section %u\n", rec->Flags.S.Section );
|
||||
ok( rec->Flags.S.CharSet == DnsCharSetUtf8, "wrong charset %u\n", rec->Flags.S.CharSet );
|
||||
ok( rec->wType == DNS_TYPE_SRV, "wrong type %u\n", rec->wType );
|
||||
- todo_wine
|
||||
ok( rec->wDataLength == sizeof(DNS_SRV_DATAA) + strlen( "dc.winehq.org" ) + 1, "wrong len %u\n", rec->wDataLength );
|
||||
ok( rec->dwTtl == 0x04050607, "wrong ttl %#lx\n", rec->dwTtl );
|
||||
ok( !strcmp( rec->Data.SRV.pNameTarget, "dc.winehq.org"), "wrong target %s\n", rec->Data.SRV.pNameTarget );
|
||||
--
|
||||
2.40.1
|
||||
|
1
patches/dnsapi_dns_records/definition
Normal file
1
patches/dnsapi_dns_records/definition
Normal file
@ -0,0 +1 @@
|
||||
Fixes: [54998] - DnsQuery(DNS_TYPE_SRV) fails to parse some of the server answers
|
Loading…
Reference in New Issue
Block a user