Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
bf1486af
Commit
bf1486af
authored
Nov 02, 2021
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dnsapi: Use CRT memory allocation functions.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
da65aa5b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
74 additions
and
85 deletions
+74
-85
dnsapi.h
dlls/dnsapi/dnsapi.h
+10
-10
name.c
dlls/dnsapi/name.c
+4
-4
query.c
dlls/dnsapi/query.c
+6
-6
record.c
dlls/dnsapi/record.c
+54
-65
No files found.
dlls/dnsapi/dnsapi.h
View file @
bf1486af
...
...
@@ -18,18 +18,18 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdlib.h>
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "winternl.h"
#include "wine/heap.h"
#include "wine/unixlib.h"
static
inline
char
*
strdup_a
(
const
char
*
src
)
{
char
*
dst
;
if
(
!
src
)
return
NULL
;
dst
=
heap_
alloc
(
(
lstrlenA
(
src
)
+
1
)
*
sizeof
(
char
)
);
dst
=
m
alloc
(
(
lstrlenA
(
src
)
+
1
)
*
sizeof
(
char
)
);
if
(
dst
)
lstrcpyA
(
dst
,
src
);
return
dst
;
}
...
...
@@ -38,7 +38,7 @@ static inline char *strdup_u( const char *src )
{
char
*
dst
;
if
(
!
src
)
return
NULL
;
dst
=
heap_
alloc
(
(
strlen
(
src
)
+
1
)
*
sizeof
(
char
)
);
dst
=
m
alloc
(
(
strlen
(
src
)
+
1
)
*
sizeof
(
char
)
);
if
(
dst
)
strcpy
(
dst
,
src
);
return
dst
;
}
...
...
@@ -47,7 +47,7 @@ static inline WCHAR *strdup_w( const WCHAR *src )
{
WCHAR
*
dst
;
if
(
!
src
)
return
NULL
;
dst
=
heap_
alloc
(
(
lstrlenW
(
src
)
+
1
)
*
sizeof
(
WCHAR
)
);
dst
=
m
alloc
(
(
lstrlenW
(
src
)
+
1
)
*
sizeof
(
WCHAR
)
);
if
(
dst
)
lstrcpyW
(
dst
,
src
);
return
dst
;
}
...
...
@@ -58,7 +58,7 @@ static inline WCHAR *strdup_aw( const char *str )
if
(
str
)
{
DWORD
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
str
,
-
1
,
NULL
,
0
);
if
((
ret
=
heap_
alloc
(
len
*
sizeof
(
WCHAR
)
)))
if
((
ret
=
m
alloc
(
len
*
sizeof
(
WCHAR
)
)))
MultiByteToWideChar
(
CP_ACP
,
0
,
str
,
-
1
,
ret
,
len
);
}
return
ret
;
...
...
@@ -70,7 +70,7 @@ static inline WCHAR *strdup_uw( const char *str )
if
(
str
)
{
DWORD
len
=
MultiByteToWideChar
(
CP_UTF8
,
0
,
str
,
-
1
,
NULL
,
0
);
if
((
ret
=
heap_
alloc
(
len
*
sizeof
(
WCHAR
)
)))
if
((
ret
=
m
alloc
(
len
*
sizeof
(
WCHAR
)
)))
MultiByteToWideChar
(
CP_UTF8
,
0
,
str
,
-
1
,
ret
,
len
);
}
return
ret
;
...
...
@@ -82,7 +82,7 @@ static inline char *strdup_wa( const WCHAR *str )
if
(
str
)
{
DWORD
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
str
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
if
((
ret
=
heap_
alloc
(
len
)))
if
((
ret
=
m
alloc
(
len
)))
WideCharToMultiByte
(
CP_ACP
,
0
,
str
,
-
1
,
ret
,
len
,
NULL
,
NULL
);
}
return
ret
;
...
...
@@ -94,7 +94,7 @@ static inline char *strdup_wu( const WCHAR *str )
if
(
str
)
{
DWORD
len
=
WideCharToMultiByte
(
CP_UTF8
,
0
,
str
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
if
((
ret
=
heap_
alloc
(
len
)))
if
((
ret
=
m
alloc
(
len
)))
WideCharToMultiByte
(
CP_UTF8
,
0
,
str
,
-
1
,
ret
,
len
,
NULL
,
NULL
);
}
return
ret
;
...
...
@@ -107,7 +107,7 @@ static inline char *strdup_au( const char *src )
if
(
ret
)
{
dst
=
strdup_wu
(
ret
);
heap_
free
(
ret
);
free
(
ret
);
}
return
dst
;
}
...
...
@@ -119,7 +119,7 @@ static inline char *strdup_ua( const char *src )
if
(
ret
)
{
dst
=
strdup_wa
(
ret
);
heap_
free
(
ret
);
free
(
ret
);
}
return
dst
;
}
...
...
dlls/dnsapi/name.c
View file @
bf1486af
...
...
@@ -47,8 +47,8 @@ BOOL WINAPI DnsNameCompare_A( PCSTR name1, PCSTR name2 )
ret
=
DnsNameCompare_W
(
name1W
,
name2W
);
heap_
free
(
name1W
);
heap_
free
(
name2W
);
free
(
name1W
);
free
(
name2W
);
return
ret
;
}
...
...
@@ -89,7 +89,7 @@ DNS_STATUS WINAPI DnsValidateName_A( PCSTR name, DNS_NAME_FORMAT format )
nameW
=
strdup_aw
(
name
);
ret
=
DnsValidateName_W
(
nameW
,
format
);
heap_
free
(
nameW
);
free
(
nameW
);
return
ret
;
}
...
...
@@ -107,7 +107,7 @@ DNS_STATUS WINAPI DnsValidateName_UTF8( PCSTR name, DNS_NAME_FORMAT format )
nameW
=
strdup_uw
(
name
);
ret
=
DnsValidateName_W
(
nameW
,
format
);
heap_
free
(
nameW
);
free
(
nameW
);
return
ret
;
}
...
...
dlls/dnsapi/query.c
View file @
bf1486af
...
...
@@ -65,7 +65,7 @@ static DNS_STATUS do_query_netbios( PCSTR name, DNS_RECORDA **recp )
for
(
i
=
0
;
i
<
header
->
node_count
;
i
++
)
{
record
=
heap_alloc_zero
(
sizeof
(
DNS_RECORDA
)
);
record
=
calloc
(
1
,
sizeof
(
DNS_RECORDA
)
);
if
(
!
record
)
{
status
=
ERROR_NOT_ENOUGH_MEMORY
;
...
...
@@ -156,7 +156,7 @@ DNS_STATUS WINAPI DnsQuery_A( PCSTR name, WORD type, DWORD options, PVOID server
DnsRecordListFree
(
(
DNS_RECORD
*
)
resultW
,
DnsFreeRecordList
);
}
heap_
free
(
nameW
);
free
(
nameW
);
return
status
;
}
...
...
@@ -246,7 +246,7 @@ DNS_STATUS WINAPI DnsQuery_W( PCWSTR name, WORD type, DWORD options, PVOID serve
DnsRecordListFree
(
(
DNS_RECORD
*
)
resultA
,
DnsFreeRecordList
);
}
heap_
free
(
nameU
);
free
(
nameU
);
return
status
;
}
...
...
@@ -306,8 +306,8 @@ static DNS_STATUS get_dns_server_list( IP4_ARRAY *out, DWORD *len )
}
if
(
!
ret
)
break
;
if
((
char
*
)
servers
!=
buf
)
heap_
free
(
servers
);
servers
=
heap_
alloc
(
array_len
);
if
((
char
*
)
servers
!=
buf
)
free
(
servers
);
servers
=
m
alloc
(
array_len
);
if
(
!
servers
)
{
ret
=
ERROR_NOT_ENOUGH_MEMORY
;
...
...
@@ -322,7 +322,7 @@ static DNS_STATUS get_dns_server_list( IP4_ARRAY *out, DWORD *len )
ret
=
ERROR_SUCCESS
;
err:
if
((
char
*
)
servers
!=
buf
)
heap_
free
(
servers
);
if
((
char
*
)
servers
!=
buf
)
free
(
servers
);
return
ret
;
}
...
...
dlls/dnsapi/record.c
View file @
bf1486af
...
...
@@ -447,7 +447,7 @@ BOOL WINAPI DnsRecordCompare( PDNS_RECORD r1, PDNS_RECORD r2 )
return
TRUE
;
}
static
LPVOID
str
cpy
X
(
LPCVOID
src
,
DNS_CHARSET
in
,
DNS_CHARSET
out
)
static
LPVOID
str
dup
X
(
LPCVOID
src
,
DNS_CHARSET
in
,
DNS_CHARSET
out
)
{
switch
(
in
)
{
...
...
@@ -505,7 +505,7 @@ PDNS_RECORD WINAPI DnsRecordCopyEx( PDNS_RECORD src, DNS_CHARSET in, DNS_CHARSET
TRACE
(
"(%p,%d,%d)
\n
"
,
src
,
in
,
out
);
size
=
FIELD_OFFSET
(
DNS_RECORD
,
Data
)
+
src
->
wDataLength
;
dst
=
heap_alloc_zero
(
size
);
dst
=
malloc
(
size
);
if
(
!
dst
)
return
NULL
;
memcpy
(
dst
,
src
,
size
);
...
...
@@ -515,7 +515,7 @@ PDNS_RECORD WINAPI DnsRecordCopyEx( PDNS_RECORD src, DNS_CHARSET in, DNS_CHARSET
src
->
Flags
.
S
.
CharSet
==
DnsCharSetUnicode
)
in
=
src
->
Flags
.
S
.
CharSet
;
dst
->
Flags
.
S
.
CharSet
=
out
;
dst
->
pName
=
str
cpy
X
(
src
->
pName
,
in
,
out
);
dst
->
pName
=
str
dup
X
(
src
->
pName
,
in
,
out
);
if
(
!
dst
->
pName
)
goto
error
;
switch
(
src
->
wType
)
...
...
@@ -527,10 +527,10 @@ PDNS_RECORD WINAPI DnsRecordCopyEx( PDNS_RECORD src, DNS_CHARSET in, DNS_CHARSET
{
for
(
i
=
0
;
i
<
src
->
Data
.
TXT
.
dwStringCount
;
i
++
)
{
dst
->
Data
.
TXT
.
pStringArray
[
i
]
=
str
cpy
X
(
src
->
Data
.
TXT
.
pStringArray
[
i
],
in
,
out
);
dst
->
Data
.
TXT
.
pStringArray
[
i
]
=
str
dup
X
(
src
->
Data
.
TXT
.
pStringArray
[
i
],
in
,
out
);
if
(
!
dst
->
Data
.
TXT
.
pStringArray
[
i
])
{
while
(
i
>
0
)
heap_
free
(
dst
->
Data
.
TXT
.
pStringArray
[
--
i
]
);
while
(
i
>
0
)
free
(
dst
->
Data
.
TXT
.
pStringArray
[
--
i
]
);
goto
error
;
}
}
...
...
@@ -539,13 +539,13 @@ PDNS_RECORD WINAPI DnsRecordCopyEx( PDNS_RECORD src, DNS_CHARSET in, DNS_CHARSET
case
DNS_TYPE_MINFO
:
case
DNS_TYPE_RP
:
{
dst
->
Data
.
MINFO
.
pNameMailbox
=
str
cpy
X
(
src
->
Data
.
MINFO
.
pNameMailbox
,
in
,
out
);
dst
->
Data
.
MINFO
.
pNameMailbox
=
str
dup
X
(
src
->
Data
.
MINFO
.
pNameMailbox
,
in
,
out
);
if
(
!
dst
->
Data
.
MINFO
.
pNameMailbox
)
goto
error
;
dst
->
Data
.
MINFO
.
pNameErrorsMailbox
=
str
cpy
X
(
src
->
Data
.
MINFO
.
pNameErrorsMailbox
,
in
,
out
);
dst
->
Data
.
MINFO
.
pNameErrorsMailbox
=
str
dup
X
(
src
->
Data
.
MINFO
.
pNameErrorsMailbox
,
in
,
out
);
if
(
!
dst
->
Data
.
MINFO
.
pNameErrorsMailbox
)
{
heap_
free
(
dst
->
Data
.
MINFO
.
pNameMailbox
);
free
(
dst
->
Data
.
MINFO
.
pNameMailbox
);
goto
error
;
}
...
...
@@ -559,7 +559,7 @@ PDNS_RECORD WINAPI DnsRecordCopyEx( PDNS_RECORD src, DNS_CHARSET in, DNS_CHARSET
case
DNS_TYPE_RT
:
case
DNS_TYPE_MX
:
{
dst
->
Data
.
MX
.
pNameExchange
=
str
cpy
X
(
src
->
Data
.
MX
.
pNameExchange
,
in
,
out
);
dst
->
Data
.
MX
.
pNameExchange
=
str
dup
X
(
src
->
Data
.
MX
.
pNameExchange
,
in
,
out
);
if
(
!
dst
->
Data
.
MX
.
pNameExchange
)
goto
error
;
dst
->
wDataLength
=
sizeof
(
dst
->
Data
.
MX
);
...
...
@@ -569,7 +569,7 @@ PDNS_RECORD WINAPI DnsRecordCopyEx( PDNS_RECORD src, DNS_CHARSET in, DNS_CHARSET
}
case
DNS_TYPE_NXT
:
{
dst
->
Data
.
NXT
.
pNameNext
=
str
cpy
X
(
src
->
Data
.
NXT
.
pNameNext
,
in
,
out
);
dst
->
Data
.
NXT
.
pNameNext
=
str
dup
X
(
src
->
Data
.
NXT
.
pNameNext
,
in
,
out
);
if
(
!
dst
->
Data
.
NXT
.
pNameNext
)
goto
error
;
dst
->
wDataLength
=
sizeof
(
dst
->
Data
.
NXT
);
...
...
@@ -586,7 +586,7 @@ PDNS_RECORD WINAPI DnsRecordCopyEx( PDNS_RECORD src, DNS_CHARSET in, DNS_CHARSET
case
DNS_TYPE_NS
:
case
DNS_TYPE_PTR
:
{
dst
->
Data
.
PTR
.
pNameHost
=
str
cpy
X
(
src
->
Data
.
PTR
.
pNameHost
,
in
,
out
);
dst
->
Data
.
PTR
.
pNameHost
=
str
dup
X
(
src
->
Data
.
PTR
.
pNameHost
,
in
,
out
);
if
(
!
dst
->
Data
.
PTR
.
pNameHost
)
goto
error
;
dst
->
wDataLength
=
sizeof
(
dst
->
Data
.
PTR
);
...
...
@@ -596,7 +596,7 @@ PDNS_RECORD WINAPI DnsRecordCopyEx( PDNS_RECORD src, DNS_CHARSET in, DNS_CHARSET
}
case
DNS_TYPE_SIG
:
{
dst
->
Data
.
SIG
.
pNameSigner
=
str
cpy
X
(
src
->
Data
.
SIG
.
pNameSigner
,
in
,
out
);
dst
->
Data
.
SIG
.
pNameSigner
=
str
dup
X
(
src
->
Data
.
SIG
.
pNameSigner
,
in
,
out
);
if
(
!
dst
->
Data
.
SIG
.
pNameSigner
)
goto
error
;
dst
->
wDataLength
=
sizeof
(
dst
->
Data
.
SIG
);
...
...
@@ -606,13 +606,13 @@ PDNS_RECORD WINAPI DnsRecordCopyEx( PDNS_RECORD src, DNS_CHARSET in, DNS_CHARSET
}
case
DNS_TYPE_SOA
:
{
dst
->
Data
.
SOA
.
pNamePrimaryServer
=
str
cpy
X
(
src
->
Data
.
SOA
.
pNamePrimaryServer
,
in
,
out
);
dst
->
Data
.
SOA
.
pNamePrimaryServer
=
str
dup
X
(
src
->
Data
.
SOA
.
pNamePrimaryServer
,
in
,
out
);
if
(
!
dst
->
Data
.
SOA
.
pNamePrimaryServer
)
goto
error
;
dst
->
Data
.
SOA
.
pNameAdministrator
=
str
cpy
X
(
src
->
Data
.
SOA
.
pNameAdministrator
,
in
,
out
);
dst
->
Data
.
SOA
.
pNameAdministrator
=
str
dup
X
(
src
->
Data
.
SOA
.
pNameAdministrator
,
in
,
out
);
if
(
!
dst
->
Data
.
SOA
.
pNameAdministrator
)
{
heap_
free
(
dst
->
Data
.
SOA
.
pNamePrimaryServer
);
free
(
dst
->
Data
.
SOA
.
pNamePrimaryServer
);
goto
error
;
}
...
...
@@ -624,7 +624,7 @@ PDNS_RECORD WINAPI DnsRecordCopyEx( PDNS_RECORD src, DNS_CHARSET in, DNS_CHARSET
}
case
DNS_TYPE_SRV
:
{
dst
->
Data
.
SRV
.
pNameTarget
=
str
cpy
X
(
src
->
Data
.
SRV
.
pNameTarget
,
in
,
out
);
dst
->
Data
.
SRV
.
pNameTarget
=
str
dup
X
(
src
->
Data
.
SRV
.
pNameTarget
,
in
,
out
);
if
(
!
dst
->
Data
.
SRV
.
pNameTarget
)
goto
error
;
dst
->
wDataLength
=
sizeof
(
dst
->
Data
.
SRV
);
...
...
@@ -638,8 +638,8 @@ PDNS_RECORD WINAPI DnsRecordCopyEx( PDNS_RECORD src, DNS_CHARSET in, DNS_CHARSET
return
dst
;
error:
heap_
free
(
dst
->
pName
);
heap_
free
(
dst
);
free
(
dst
->
pName
);
free
(
dst
);
return
NULL
;
}
...
...
@@ -662,7 +662,7 @@ VOID WINAPI DnsRecordListFree( PDNS_RECORD list, DNS_FREE_TYPE type )
{
for
(
r
=
list
;
(
list
=
r
);
r
=
next
)
{
heap_
free
(
r
->
pName
);
free
(
r
->
pName
);
switch
(
r
->
wType
)
{
...
...
@@ -670,31 +670,27 @@ VOID WINAPI DnsRecordListFree( PDNS_RECORD list, DNS_FREE_TYPE type )
case
DNS_TYPE_ISDN
:
case
DNS_TYPE_TEXT
:
case
DNS_TYPE_X25
:
{
for
(
i
=
0
;
i
<
r
->
Data
.
TXT
.
dwStringCount
;
i
++
)
heap_
free
(
r
->
Data
.
TXT
.
pStringArray
[
i
]
);
free
(
r
->
Data
.
TXT
.
pStringArray
[
i
]
);
break
;
}
case
DNS_TYPE_MINFO
:
case
DNS_TYPE_RP
:
{
heap_free
(
r
->
Data
.
MINFO
.
pNameMailbox
);
heap_free
(
r
->
Data
.
MINFO
.
pNameErrorsMailbox
);
free
(
r
->
Data
.
MINFO
.
pNameMailbox
);
free
(
r
->
Data
.
MINFO
.
pNameErrorsMailbox
);
break
;
}
case
DNS_TYPE_AFSDB
:
case
DNS_TYPE_RT
:
case
DNS_TYPE_MX
:
{
heap_free
(
r
->
Data
.
MX
.
pNameExchange
);
free
(
r
->
Data
.
MX
.
pNameExchange
);
break
;
}
case
DNS_TYPE_NXT
:
{
heap_free
(
r
->
Data
.
NXT
.
pNameNext
);
free
(
r
->
Data
.
NXT
.
pNameNext
);
break
;
}
case
DNS_TYPE_CNAME
:
case
DNS_TYPE_MB
:
case
DNS_TYPE_MD
:
...
...
@@ -703,32 +699,25 @@ VOID WINAPI DnsRecordListFree( PDNS_RECORD list, DNS_FREE_TYPE type )
case
DNS_TYPE_MR
:
case
DNS_TYPE_NS
:
case
DNS_TYPE_PTR
:
{
heap_free
(
r
->
Data
.
PTR
.
pNameHost
);
free
(
r
->
Data
.
PTR
.
pNameHost
);
break
;
}
case
DNS_TYPE_SIG
:
{
heap_free
(
r
->
Data
.
SIG
.
pNameSigner
);
free
(
r
->
Data
.
SIG
.
pNameSigner
);
break
;
}
case
DNS_TYPE_SOA
:
{
heap_free
(
r
->
Data
.
SOA
.
pNamePrimaryServer
);
heap_free
(
r
->
Data
.
SOA
.
pNameAdministrator
);
free
(
r
->
Data
.
SOA
.
pNamePrimaryServer
);
free
(
r
->
Data
.
SOA
.
pNameAdministrator
);
break
;
}
case
DNS_TYPE_SRV
:
{
heap_free
(
r
->
Data
.
SRV
.
pNameTarget
);
break
;
}
default:
free
(
r
->
Data
.
SRV
.
pNameTarget
);
break
;
}
next
=
r
->
pNext
;
heap_
free
(
r
);
free
(
r
);
}
break
;
}
...
...
@@ -969,11 +958,11 @@ static DNS_STATUS extract_rdata( const BYTE *base, const BYTE *end, const BYTE *
case
DNS_TYPE_RP
:
case
DNS_TYPE_MINFO
:
if
(
!
(
pos
=
get_name
(
base
,
end
,
pos
,
name
)))
return
DNS_ERROR_BAD_PACKET
;
if
(
!
(
r
->
Data
.
MINFO
.
pNameMailbox
=
str
cpy
X
(
name
,
in
,
out
)))
return
ERROR_NOT_ENOUGH_MEMORY
;
if
(
!
(
r
->
Data
.
MINFO
.
pNameMailbox
=
str
dup
X
(
name
,
in
,
out
)))
return
ERROR_NOT_ENOUGH_MEMORY
;
if
(
!
get_name
(
base
,
end
,
pos
,
name
))
return
DNS_ERROR_BAD_PACKET
;
if
(
!
(
r
->
Data
.
MINFO
.
pNameErrorsMailbox
=
str
cpy
X
(
name
,
in
,
out
)))
if
(
!
(
r
->
Data
.
MINFO
.
pNameErrorsMailbox
=
str
dup
X
(
name
,
in
,
out
)))
{
heap_
free
(
r
->
Data
.
MINFO
.
pNameMailbox
);
free
(
r
->
Data
.
MINFO
.
pNameMailbox
);
return
ERROR_NOT_ENOUGH_MEMORY
;
}
r
->
wDataLength
=
sizeof
(
DNS_MINFO_DATAA
);
...
...
@@ -985,7 +974,7 @@ static DNS_STATUS extract_rdata( const BYTE *base, const BYTE *end, const BYTE *
if
(
pos
+
sizeof
(
WORD
)
>
rrend
)
return
DNS_ERROR_BAD_PACKET
;
r
->
Data
.
MX
.
wPreference
=
get_word
(
&
pos
);
if
(
!
get_name
(
base
,
end
,
pos
,
name
))
return
DNS_ERROR_BAD_PACKET
;
if
(
!
(
r
->
Data
.
MX
.
pNameExchange
=
str
cpy
X
(
name
,
in
,
out
)))
return
ERROR_NOT_ENOUGH_MEMORY
;
if
(
!
(
r
->
Data
.
MX
.
pNameExchange
=
str
dup
X
(
name
,
in
,
out
)))
return
ERROR_NOT_ENOUGH_MEMORY
;
r
->
wDataLength
=
sizeof
(
DNS_MX_DATAA
)
+
sizeof
(
DWORD
);
break
;
...
...
@@ -1011,7 +1000,7 @@ static DNS_STATUS extract_rdata( const BYTE *base, const BYTE *end, const BYTE *
case
DNS_TYPE_MR
:
case
DNS_TYPE_PTR
:
if
(
!
get_name
(
base
,
end
,
pos
,
name
))
return
DNS_ERROR_BAD_PACKET
;
if
(
!
(
r
->
Data
.
PTR
.
pNameHost
=
str
cpy
X
(
name
,
in
,
out
)))
return
ERROR_NOT_ENOUGH_MEMORY
;
if
(
!
(
r
->
Data
.
PTR
.
pNameHost
=
str
dup
X
(
name
,
in
,
out
)))
return
ERROR_NOT_ENOUGH_MEMORY
;
r
->
wDataLength
=
sizeof
(
DNS_PTR_DATAA
)
+
sizeof
(
DWORD
);
break
;
...
...
@@ -1025,7 +1014,7 @@ static DNS_STATUS extract_rdata( const BYTE *base, const BYTE *end, const BYTE *
r
->
Data
.
SIG
.
dwTimeSigned
=
get_dword
(
&
pos
);
r
->
Data
.
SIG
.
wKeyTag
=
get_word
(
&
pos
);
if
(
!
(
pos
=
get_name
(
base
,
end
,
pos
,
name
)))
return
DNS_ERROR_BAD_PACKET
;
if
(
!
(
r
->
Data
.
SIG
.
pNameSigner
=
str
cpy
X
(
name
,
in
,
out
)))
return
ERROR_NOT_ENOUGH_MEMORY
;
if
(
!
(
r
->
Data
.
SIG
.
pNameSigner
=
str
dup
X
(
name
,
in
,
out
)))
return
ERROR_NOT_ENOUGH_MEMORY
;
r
->
Data
.
SIG
.
wSignatureLength
=
rrend
-
pos
;
memcpy
(
r
->
Data
.
SIG
.
Signature
,
pos
,
r
->
Data
.
SIG
.
wSignatureLength
);
r
->
wDataLength
=
offsetof
(
DNS_SIG_DATAA
,
Signature
[
r
->
Data
.
SIG
.
wSignatureLength
]
);
...
...
@@ -1033,11 +1022,11 @@ static DNS_STATUS extract_rdata( const BYTE *base, const BYTE *end, const BYTE *
case
DNS_TYPE_SOA
:
if
(
!
(
pos
=
get_name
(
base
,
end
,
pos
,
name
)))
return
DNS_ERROR_BAD_PACKET
;
if
(
!
(
r
->
Data
.
SOA
.
pNamePrimaryServer
=
str
cpy
X
(
name
,
in
,
out
)))
return
ERROR_NOT_ENOUGH_MEMORY
;
if
(
!
(
r
->
Data
.
SOA
.
pNamePrimaryServer
=
str
dup
X
(
name
,
in
,
out
)))
return
ERROR_NOT_ENOUGH_MEMORY
;
if
(
!
(
pos
=
get_name
(
base
,
end
,
pos
,
name
)))
return
DNS_ERROR_BAD_PACKET
;
if
(
!
(
r
->
Data
.
SOA
.
pNameAdministrator
=
str
cpy
X
(
name
,
in
,
out
)))
if
(
!
(
r
->
Data
.
SOA
.
pNameAdministrator
=
str
dup
X
(
name
,
in
,
out
)))
{
heap_
free
(
r
->
Data
.
SOA
.
pNamePrimaryServer
);
free
(
r
->
Data
.
SOA
.
pNamePrimaryServer
);
return
ERROR_NOT_ENOUGH_MEMORY
;
}
if
(
pos
+
5
*
sizeof
(
DWORD
)
>
rrend
)
return
DNS_ERROR_BAD_PACKET
;
...
...
@@ -1055,7 +1044,7 @@ static DNS_STATUS extract_rdata( const BYTE *base, const BYTE *end, const BYTE *
r
->
Data
.
SRV
.
wWeight
=
get_word
(
&
pos
);
r
->
Data
.
SRV
.
wPort
=
get_word
(
&
pos
);
if
(
!
get_name
(
base
,
end
,
pos
,
name
))
return
DNS_ERROR_BAD_PACKET
;
if
(
!
(
r
->
Data
.
SRV
.
pNameTarget
=
str
cpy
X
(
name
,
in
,
out
)))
return
ERROR_NOT_ENOUGH_MEMORY
;
if
(
!
(
r
->
Data
.
SRV
.
pNameTarget
=
str
dup
X
(
name
,
in
,
out
)))
return
ERROR_NOT_ENOUGH_MEMORY
;
r
->
wDataLength
=
sizeof
(
DNS_SRV_DATAA
);
break
;
...
...
@@ -1069,9 +1058,9 @@ static DNS_STATUS extract_rdata( const BYTE *base, const BYTE *end, const BYTE *
if
(
pos
+
len
+
1
>
rrend
)
return
DNS_ERROR_BAD_PACKET
;
memcpy
(
name
,
pos
+
1
,
len
);
name
[
len
]
=
0
;
if
(
!
(
r
->
Data
.
TXT
.
pStringArray
[
i
]
=
str
cpy
X
(
name
,
in
,
out
)))
if
(
!
(
r
->
Data
.
TXT
.
pStringArray
[
i
]
=
str
dup
X
(
name
,
in
,
out
)))
{
while
(
i
>
0
)
heap_
free
(
r
->
Data
.
TXT
.
pStringArray
[
--
i
]
);
while
(
i
>
0
)
free
(
r
->
Data
.
TXT
.
pStringArray
[
--
i
]
);
return
ERROR_NOT_ENOUGH_MEMORY
;
}
pos
+=
len
+
1
;
...
...
@@ -1117,22 +1106,22 @@ static DNS_STATUS extract_record( const DNS_MESSAGE_BUFFER *hdr, const BYTE *end
if
(
ptr
+
rdlen
>
end
)
return
DNS_ERROR_BAD_PACKET
;
*
pos
=
ptr
+
rdlen
;
if
(
!
(
record
=
heap_alloc_zero
(
get_record_size
(
type
,
ptr
,
rdlen
)
)))
return
ERROR_NOT_ENOUGH_MEMORY
;
if
(
!
(
record
=
calloc
(
1
,
get_record_size
(
type
,
ptr
,
rdlen
)
)))
return
ERROR_NOT_ENOUGH_MEMORY
;
record
->
wType
=
type
;
record
->
Flags
.
S
.
Section
=
section
;
record
->
Flags
.
S
.
CharSet
=
charset
;
record
->
dwTtl
=
ttl
;
if
(
!
(
record
->
pName
=
str
cpy
X
(
name
,
DnsCharSetUtf8
,
charset
)))
if
(
!
(
record
->
pName
=
str
dup
X
(
name
,
DnsCharSetUtf8
,
charset
)))
{
heap_
free
(
record
);
free
(
record
);
return
ERROR_NOT_ENOUGH_MEMORY
;
}
if
((
ret
=
extract_rdata
(
base
,
end
,
ptr
,
rdlen
,
type
,
record
)))
{
heap_
free
(
record
->
pName
);
heap_
free
(
record
);
free
(
record
->
pName
);
free
(
record
);
return
ret
;
}
*
recp
=
record
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment