mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 07:42:59 +00:00
[NSLOOKUP] Fix crash in case of no network connectivity (#1354)
Prevent nslookup.exe from crashing when executed in a ROS VM with no network interfaces. This is due to a NULL pointer dereference occurring if `GetNetworkParams` in `main` fails with an error other than `ERROR_BUFFER_OVERFLOW`. In this case, `pNetInfo` remains initialized to NULL, causing `strncpy` to crash.
This commit is contained in:
parent
67a3747722
commit
42515190c5
1 changed files with 20 additions and 15 deletions
|
@ -792,8 +792,14 @@ int main( int argc, char* argv[] )
|
||||||
/* We don't know how long of a buffer it will want to return. So we'll
|
/* We don't know how long of a buffer it will want to return. So we'll
|
||||||
pass an empty one now and let it fail only once, instead of guessing. */
|
pass an empty one now and let it fail only once, instead of guessing. */
|
||||||
Status = GetNetworkParams( pNetInfo, &NetBufLen );
|
Status = GetNetworkParams( pNetInfo, &NetBufLen );
|
||||||
if( Status == ERROR_BUFFER_OVERFLOW )
|
|
||||||
|
if( Status != ERROR_BUFFER_OVERFLOW )
|
||||||
{
|
{
|
||||||
|
_tprintf( _T("Error in GetNetworkParams call\n") );
|
||||||
|
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
pNetInfo = (PFIXED_INFO)HeapAlloc( ProcessHeap, 0, NetBufLen );
|
pNetInfo = (PFIXED_INFO)HeapAlloc( ProcessHeap, 0, NetBufLen );
|
||||||
if( pNetInfo == NULL )
|
if( pNetInfo == NULL )
|
||||||
{
|
{
|
||||||
|
@ -812,7 +818,6 @@ int main( int argc, char* argv[] )
|
||||||
|
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
strncpy( State.domain, pNetInfo->DomainName, 255 );
|
strncpy( State.domain, pNetInfo->DomainName, 255 );
|
||||||
strncpy( State.srchlist[0], pNetInfo->DomainName, 255 );
|
strncpy( State.srchlist[0], pNetInfo->DomainName, 255 );
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue