mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 17:05:46 +00:00
Fix heap corruptions and memory leaks in dnsapi
Patch by Samuel Serapión with some modifications by me after discussing it with Art Yerkes See issue #3387 for more details. svn path=/trunk/; revision=34297
This commit is contained in:
parent
b82fda4139
commit
458e927317
3 changed files with 16 additions and 8 deletions
|
@ -46,6 +46,12 @@ DNS_STATUS WINAPI DnsAcquireContextHandle_W
|
|||
/* For now, don't worry about the user's identity. */
|
||||
Context = (PWINDNS_CONTEXT)RtlAllocateHeap( RtlGetProcessHeap(), 0,
|
||||
sizeof( WINDNS_CONTEXT ) );
|
||||
|
||||
if(!Context){
|
||||
*ContextHandle = 0;
|
||||
return ERROR_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
/* The real work here is to create an adns_state that will help us
|
||||
* do what we want to later. */
|
||||
adns_status = adns_init( &Context->State,
|
||||
|
@ -55,6 +61,7 @@ DNS_STATUS WINAPI DnsAcquireContextHandle_W
|
|||
0 );
|
||||
if( adns_status != adns_s_ok ) {
|
||||
*ContextHandle = 0;
|
||||
RtlFreeHeap( RtlGetProcessHeap(), 0, Context );
|
||||
return DnsIntTranslateAdnsToDNS_STATUS( adns_status );
|
||||
} else {
|
||||
*ContextHandle = (HANDLE)Context;
|
||||
|
@ -115,3 +122,4 @@ void WINAPI DnsReleaseContextHandle
|
|||
RtlFreeHeap( RtlGetProcessHeap(), 0, Context );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -145,7 +145,7 @@ DNS_STATUS WINAPI DnsValidateName_UTF8
|
|||
sizeof( WCHAR ) * (StrLenWc + 1) );
|
||||
mbstowcs( Buffer, Name, StrLenWc + 1 );
|
||||
Status = DnsValidateName_W( Buffer, Format );
|
||||
RtlFreeHeap( GetProcessHeap(), 0, Buffer );
|
||||
RtlFreeHeap( RtlGetProcessHeap(), 0, Buffer );
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
|
|
@ -102,14 +102,14 @@ DNS_STATUS WINAPI DnsQuery_A
|
|||
if( adns_error != adns_s_ok ) {
|
||||
adns_finish( astate );
|
||||
if ( CurrentName != Name ) {
|
||||
RtlFreeHeap( CurrentName, 0, GetProcessHeap() );
|
||||
RtlFreeHeap( RtlGetProcessHeap(), 0, CurrentName );
|
||||
}
|
||||
return DnsIntTranslateAdnsToDNS_STATUS( adns_error );
|
||||
}
|
||||
|
||||
if( answer && answer->rrs.addr ) {
|
||||
if ( CurrentName != Name ) {
|
||||
RtlFreeHeap( CurrentName, 0, GetProcessHeap() );
|
||||
RtlFreeHeap( RtlGetProcessHeap(), 0, CurrentName );
|
||||
}
|
||||
*QueryResultSet =
|
||||
(PDNS_RECORD)RtlAllocateHeap( RtlGetProcessHeap(), 0,
|
||||
|
@ -132,12 +132,12 @@ DNS_STATUS WINAPI DnsQuery_A
|
|||
NULL == answer->cname ) {
|
||||
adns_finish( astate );
|
||||
if ( CurrentName != Name ) {
|
||||
RtlFreeHeap( CurrentName, 0, GetProcessHeap() );
|
||||
RtlFreeHeap( RtlGetProcessHeap(), 0, CurrentName );
|
||||
}
|
||||
return ERROR_FILE_NOT_FOUND;
|
||||
}
|
||||
if ( CurrentName != Name ) {
|
||||
RtlFreeHeap( CurrentName, 0, GetProcessHeap() );
|
||||
RtlFreeHeap( RtlGetProcessHeap(), 0, CurrentName );
|
||||
}
|
||||
CurrentName = xstrsave( answer->cname );
|
||||
if ( NULL == CurrentName ) {
|
||||
|
@ -146,7 +146,7 @@ DNS_STATUS WINAPI DnsQuery_A
|
|||
}
|
||||
}
|
||||
adns_finish( astate );
|
||||
RtlFreeHeap( CurrentName, 0, GetProcessHeap() );
|
||||
RtlFreeHeap( RtlGetProcessHeap(), 0, CurrentName );
|
||||
return ERROR_FILE_NOT_FOUND;
|
||||
default:
|
||||
return ERROR_OUTOFMEMORY; /* XXX arty: find a better error code. */
|
||||
|
@ -298,8 +298,8 @@ DNS_STATUS WINAPI DnsQuery_UTF8
|
|||
PIP4_ARRAY Servers,
|
||||
PDNS_RECORD *QueryResultSet,
|
||||
PVOID *Reserved ) {
|
||||
return DnsQuery_UTF8( Name, Type, Options, Servers, QueryResultSet,
|
||||
Reserved );
|
||||
UNIMPLEMENTED;
|
||||
return ERROR_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
void DnsIntFreeRecordList( PDNS_RECORD ToDelete ) {
|
||||
|
|
Loading…
Reference in a new issue