Skip to content

Commit

Permalink
Fix null pointer dereference in setupdi_diskdrive routine
Browse files Browse the repository at this point in the history
Result of final LocalAlloc never get checked before use.
  • Loading branch information
hfiref0x committed Jan 24, 2019
1 parent c4847b2 commit 2ae73af
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions al-khaser/AntiVM/Generic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,24 +493,28 @@ BOOL setupdi_diskdrive()
// Double the size to avoid problems on
// W2k MBCS systems per KB 888609.
buffer = (LPTSTR)LocalAlloc(LPTR, dwSize * 2);
if (buffer == NULL)
break;
}
else
break;

}

// Do our comparaison
if ((StrStrI(buffer, _T("vbox")) != NULL) ||
(StrStrI(buffer, _T("vmware")) != NULL) ||
(StrStrI(buffer, _T("qemu")) != NULL) ||
(StrStrI(buffer, _T("virtual")) != NULL))
{
bFound = TRUE;
break;
if (buffer) {
// Do our comparison
if ((StrStrI(buffer, _T("vbox")) != NULL) ||
(StrStrI(buffer, _T("vmware")) != NULL) ||
(StrStrI(buffer, _T("qemu")) != NULL) ||
(StrStrI(buffer, _T("virtual")) != NULL))
{
bFound = TRUE;
break;
}
}
}

if (buffer)
if (buffer)
LocalFree(buffer);

// Cleanup
Expand All @@ -519,11 +523,7 @@ BOOL setupdi_diskdrive()
if (GetLastError() != NO_ERROR && GetLastError() != ERROR_NO_MORE_ITEMS)
return FALSE;

if (bFound)
return TRUE;

else
return FALSE;
return bFound;
}


Expand Down

0 comments on commit 2ae73af

Please sign in to comment.