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

Commit 7c3cfc3

Browse files
authored
Merge pull request #53 from github/null-map
Fix null pointer dereference in driver userclient
2 parents e795b8a + 9f4ff58 commit 7c3cfc3

3 files changed

Lines changed: 16 additions & 7 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

SoftU2FDriver/SoftU2FUserClient.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,21 +158,22 @@ void SoftU2FUserClient::frameReceivedGated(IOMemoryDescriptor *report) {
158158

159159
IOMemoryMap *reportMap = nullptr;
160160

161-
if (isInactive())
161+
if (isInactive() || !_notifyRef)
162162
return;
163163

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

167+
// Map report into kernel space.
167168
reportMap = report->map();
168169

169-
// Notify userland that we got a report.
170-
if (_notifyRef && reportMap->getLength() == sizeof(U2FHID_FRAME)) {
170+
if (reportMap != nullptr) {
171+
// Notify userland that we got a report.
171172
io_user_reference_t *args = (io_user_reference_t *)reportMap->getAddress();
172173
sendAsyncResult64(*_notifyRef, kIOReturnSuccess, args, sizeof(U2FHID_FRAME) / sizeof(io_user_reference_t));
174+
reportMap->release();
173175
}
174176

175-
reportMap->release();
176177
report->complete();
177178
}
178179

script/run

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ if kextstat -b $BUNDLE_ID | grep $BUNDLE_ID &> /dev/null; then
2020
fi
2121

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

2525
echo "Loading softu2f.kext"
26-
if ! sudo kextutil $KEXT_PATH; then
26+
if ! sudo kextutil "${KEXT_PATH}"; then
2727
echo "Error loading softu2f.kext"
2828
exit 1
2929
fi

0 commit comments

Comments
 (0)