Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixes 5 #163

Merged
merged 23 commits into from
Jan 30, 2019
Merged

Bug fixes 5 #163

merged 23 commits into from
Jan 30, 2019

Conversation

hfiref0x
Copy link
Contributor

@hfiref0x hfiref0x commented Jan 23, 2019

Fix for HardwareBreakpoints routine
Update process.cpp
Fix multiple bugs in WMI related routines
Fix memory leak in check_mac_addr routine
Update MemoryBreakpoints_PageGuard.cpp
Fix multiple bugs in ScanForModules.cpp
Fix bug in IsBadLibrary
Fix number of bugs in get_system_firmware
Fix InitWMI routine
Update IsBadLibrary
Remove incorrect result checks and wrong printf specifiers in ScanForModules.cpp
Fix null pointer dereference in qemu_firmware_ACPI routine
Fix null pointer dereferences in VirtualBox.cpp & VMWare.cpp
Fix QueueUserAPC_Injection routine by rewrite
Fix null pointer dereference in setupdi_diskdrive routine
Add error handling in log_print
Fix null pointer dereference in print_last_error routine, add more error handling
Fixes in Services.cpp
Fix signed/unsigned mismatch for specifiers in various *printf calls
Fix resource leak in timing_IcmpSendEcho routine
Fix missing VirtualAlloc checks in WriteWatch.cpp
Fix number of bugs in timing.cpp
Remove incorrect return value checks

Please review these changes because they affect all WMI related parts of your program. I tried not to screw up something but more eyes is better.

P.S.
According to ScanForModules unit. Despite patches the code for mapped/hidden modules enumeration is a mess, very slow because of ineffectiveness and bugged, I can only suggest to rewrite it from the scratch completely.

Fix null pointer dereference, fix memory leak.
Remove colon after executable name in report for better look.
Fix multiple bugs and resource leaks in routines related to the WMI in Generic.cpp, fix WMI query call in ExecWMIQuery, fix WMI related bugs in VirtualBox.cpp, fix safe array never get unlocked in vbox_eventlogfile_wmi and add more virtualbox detection markers from VirtualBox 6.0.2
The IP_ADAPTER_INFO buffer was allocated and never released.
Replace NULL with 0 where needed.
Fix null pointer dereference, realloc potential memory leak, memory leak, invalid expression in ScanForModules_EnumProcessModulesEx_Internal, fix invalid expression in ScanForModules_MemoryWalk_Hidden - invalid length always passed to IsBadLibrary, fix mismatched delete call in ScanForModules_MemoryWalk_Hidden, array was allocated wth new[] but released with delete.
normalisedPath never got normalised
Fix memory leak in case of realloc failure, fix potential null ptr passed to SecureZeroMemory.
Allocate BSTR string instead of incorrect type conversion.
Exclude SortDefault.nls false positive, please see comment. Satisfy compiler warnings.
Remove incorrect result checks and wrong printf specifiers.
Result of get_system_firmware never get checked against failure.
Similar to previos. In vmware_firmware_ACPI and vbox_firmware_ACPI get_system_firmware call never get checked against failure.
Fix QueueUserAPC_Injection routine by rewritting it and making it work.
Result of final LocalAlloc never get checked before use.
Failure of log open/create wasn't handled.
…ror handling

The LocalAlloc result was never checked against failure before use. Result of FormatMessage not checked.
Fix SCM handle leak in VMDriverServices(), fix get_services() potential realloc memory leak, null pointer dereference, wrong printf specifier.
The value passed to printf variation is all unsigned.
Allocated buffer never released, icmp handle never closed.
VirtualAlloc calls not validated against failure.
Fix handle leak, fix incorrect return value check, fix timers queue destroy.
This is a potential error, since the success value may be presented by any non-zero number while failure only by 0.
@ayoubfaouzi
Copy link
Owner

Well all seems to be fine, I went through all your changes. I need to add tests but that would be a bit challenging. Many thanks to you @hfiref0x

@ayoubfaouzi ayoubfaouzi merged commit 3bac6f7 into ayoubfaouzi:master Jan 30, 2019
@hfiref0x hfiref0x deleted the patch-5 branch January 31, 2019 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants