mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 02:03:13 +00:00
[IPHLPAPI] Use if_descrlen field for determining the length of
if_descr in IFEntry structure. This fixes heap corruption on GCC8. CORE-16088
This commit is contained in:
parent
76e00fab7e
commit
042646ceac
2 changed files with 14 additions and 13 deletions
|
@ -97,13 +97,14 @@ NTSTATUS tdiGetMibForIfEntity
|
||||||
entry->ent.if_speed,
|
entry->ent.if_speed,
|
||||||
entry->ent.if_physaddrlen);
|
entry->ent.if_physaddrlen);
|
||||||
TRACE(" if_physaddr .................... %02x:%02x:%02x:%02x:%02x:%02x\n"
|
TRACE(" if_physaddr .................... %02x:%02x:%02x:%02x:%02x:%02x\n"
|
||||||
" if_descr ....................... %s\n",
|
" if_descr ....................... %*s\n",
|
||||||
entry->ent.if_physaddr[0] & 0xff,
|
entry->ent.if_physaddr[0] & 0xff,
|
||||||
entry->ent.if_physaddr[1] & 0xff,
|
entry->ent.if_physaddr[1] & 0xff,
|
||||||
entry->ent.if_physaddr[2] & 0xff,
|
entry->ent.if_physaddr[2] & 0xff,
|
||||||
entry->ent.if_physaddr[3] & 0xff,
|
entry->ent.if_physaddr[3] & 0xff,
|
||||||
entry->ent.if_physaddr[4] & 0xff,
|
entry->ent.if_physaddr[4] & 0xff,
|
||||||
entry->ent.if_physaddr[5] & 0xff,
|
entry->ent.if_physaddr[5] & 0xff,
|
||||||
|
entry->ent.if_descrlen,
|
||||||
entry->ent.if_descr);
|
entry->ent.if_descr);
|
||||||
TRACE("} status %08x\n",status);
|
TRACE("} status %08x\n",status);
|
||||||
|
|
||||||
|
@ -332,7 +333,7 @@ NTSTATUS getInterfaceInfoByName( HANDLE tcpFile, char *name, IFInfo *info ) {
|
||||||
if( NT_SUCCESS(status) )
|
if( NT_SUCCESS(status) )
|
||||||
{
|
{
|
||||||
for( i = 0; i < numInterfaces; i++ ) {
|
for( i = 0; i < numInterfaces; i++ ) {
|
||||||
if( !strcmp((PCHAR)ifInfo[i].if_info.ent.if_descr, name) ) {
|
if( !strncmp((PCHAR)ifInfo[i].if_info.ent.if_descr, name, ifInfo[i].if_info.ent.if_descrlen) ) {
|
||||||
memcpy( info, &ifInfo[i], sizeof(*info) );
|
memcpy( info, &ifInfo[i], sizeof(*info) );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -352,20 +353,19 @@ const char *getInterfaceNameByIndex(DWORD index)
|
||||||
{
|
{
|
||||||
IFInfo ifInfo;
|
IFInfo ifInfo;
|
||||||
HANDLE tcpFile;
|
HANDLE tcpFile;
|
||||||
char *interfaceName = 0, *adapter_name = 0;
|
char *interfaceName = NULL;
|
||||||
NTSTATUS status = openTcpFile( &tcpFile, FILE_READ_DATA );
|
NTSTATUS status = openTcpFile( &tcpFile, FILE_READ_DATA );
|
||||||
|
|
||||||
if( NT_SUCCESS(status) ) {
|
if( NT_SUCCESS(status) ) {
|
||||||
status = getInterfaceInfoByIndex( tcpFile, index, &ifInfo );
|
status = getInterfaceInfoByIndex( tcpFile, index, &ifInfo );
|
||||||
|
|
||||||
if( NT_SUCCESS(status) ) {
|
if( NT_SUCCESS(status) ) {
|
||||||
adapter_name = (char *)ifInfo.if_info.ent.if_descr;
|
|
||||||
|
|
||||||
interfaceName = HeapAlloc( GetProcessHeap(), 0,
|
interfaceName = HeapAlloc( GetProcessHeap(), 0,
|
||||||
strlen(adapter_name) + 1 );
|
ifInfo.if_info.ent.if_descrlen + 1 );
|
||||||
if (!interfaceName) return NULL;
|
if( interfaceName ) {
|
||||||
|
memcpy(interfaceName, ifInfo.if_info.ent.if_descr, ifInfo.if_info.ent.if_descrlen);
|
||||||
strcpy( interfaceName, adapter_name );
|
interfaceName[ifInfo.if_info.ent.if_descrlen] = '\0';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
closeTcpFile( tcpFile );
|
closeTcpFile( tcpFile );
|
||||||
|
|
|
@ -3200,10 +3200,10 @@ DWORD WINAPI DECLSPEC_HOTPATCH GetAdaptersAddresses(ULONG Family,ULONG Flags,PVO
|
||||||
|
|
||||||
/* Friendly name */
|
/* Friendly name */
|
||||||
if (!(Flags & GAA_FLAG_SKIP_FRIENDLY_NAME))
|
if (!(Flags & GAA_FLAG_SKIP_FRIENDLY_NAME))
|
||||||
requiredSize += strlen((char *)ifInfo.if_info.ent.if_descr) + 1; //FIXME
|
requiredSize += ifInfo.if_info.ent.if_descrlen + 1; //FIXME
|
||||||
|
|
||||||
/* Adapter name */
|
/* Adapter name */
|
||||||
requiredSize += strlen((char *)ifInfo.if_info.ent.if_descr) + 1;
|
requiredSize += ifInfo.if_info.ent.if_descrlen + 1;
|
||||||
|
|
||||||
/* Unicast address */
|
/* Unicast address */
|
||||||
if (!(Flags & GAA_FLAG_SKIP_UNICAST))
|
if (!(Flags & GAA_FLAG_SKIP_UNICAST))
|
||||||
|
@ -3248,7 +3248,7 @@ DWORD WINAPI DECLSPEC_HOTPATCH GetAdaptersAddresses(ULONG Family,ULONG Flags,PVO
|
||||||
|
|
||||||
/* Adapter name */
|
/* Adapter name */
|
||||||
currentAddress->AdapterName = (PVOID)currentLocation;
|
currentAddress->AdapterName = (PVOID)currentLocation;
|
||||||
currentLocation += strlen((char *)ifInfo.if_info.ent.if_descr) + 1;
|
currentLocation += ifInfo.if_info.ent.if_descrlen + 1;
|
||||||
|
|
||||||
/* Unicast address */
|
/* Unicast address */
|
||||||
if (!(Flags & GAA_FLAG_SKIP_UNICAST))
|
if (!(Flags & GAA_FLAG_SKIP_UNICAST))
|
||||||
|
@ -3297,7 +3297,8 @@ DWORD WINAPI DECLSPEC_HOTPATCH GetAdaptersAddresses(ULONG Family,ULONG Flags,PVO
|
||||||
currentAddress->IfIndex = indexTable->indexes[i];
|
currentAddress->IfIndex = indexTable->indexes[i];
|
||||||
|
|
||||||
/* Adapter name */
|
/* Adapter name */
|
||||||
strcpy(currentAddress->AdapterName, (char *)ifInfo.if_info.ent.if_descr);
|
memcpy(currentAddress->AdapterName, ifInfo.if_info.ent.if_descr, ifInfo.if_info.ent.if_descrlen);
|
||||||
|
currentAddress->AdapterName[ifInfo.if_info.ent.if_descrlen] = '\0';
|
||||||
|
|
||||||
if (!(Flags & GAA_FLAG_SKIP_UNICAST))
|
if (!(Flags & GAA_FLAG_SKIP_UNICAST))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue