Skip to content
This repository has been archived by the owner on Dec 15, 2020. It is now read-only.

Commit

Permalink
Merge pull request #53 from github/null-map
Browse files Browse the repository at this point in the history
Fix null pointer dereference in driver userclient
  • Loading branch information
mastahyeti authored Jun 19, 2018
2 parents e795b8a + 9f4ff58 commit 7c3cfc3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
11 changes: 6 additions & 5 deletions SoftU2FDriver/SoftU2FUserClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,21 +158,22 @@ void SoftU2FUserClient::frameReceivedGated(IOMemoryDescriptor *report) {

IOMemoryMap *reportMap = nullptr;

if (isInactive())
if (isInactive() || !_notifyRef)
return;

if (report->prepare() != kIOReturnSuccess)
if (report->getLength() != sizeof(U2FHID_FRAME) || report->prepare() != kIOReturnSuccess)
return;

// Map report into kernel space.
reportMap = report->map();

// Notify userland that we got a report.
if (_notifyRef && reportMap->getLength() == sizeof(U2FHID_FRAME)) {
if (reportMap != nullptr) {
// Notify userland that we got a report.
io_user_reference_t *args = (io_user_reference_t *)reportMap->getAddress();
sendAsyncResult64(*_notifyRef, kIOReturnSuccess, args, sizeof(U2FHID_FRAME) / sizeof(io_user_reference_t));
reportMap->release();
}

reportMap->release();
report->complete();
}

Expand Down
4 changes: 2 additions & 2 deletions script/run
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ if kextstat -b $BUNDLE_ID | grep $BUNDLE_ID &> /dev/null; then
fi

# Ensure kext is owned by root.
sudo chown -R root:wheel $KEXT_PATH
sudo chown -R root:wheel "${KEXT_PATH}"

echo "Loading softu2f.kext"
if ! sudo kextutil $KEXT_PATH; then
if ! sudo kextutil "${KEXT_PATH}"; then
echo "Error loading softu2f.kext"
exit 1
fi
Expand Down

0 comments on commit 7c3cfc3

Please sign in to comment.