Closed Bug 932902 Opened 13 years ago Closed 8 years ago

BluetoothOppManager.cpp unsafe type mixing

Categories

(Firefox OS Graveyard :: Bluetooth, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED INCOMPLETE

People

(Reporter: rfletcher, Unassigned)

Details

(Keywords: csectype-intoverflow, sec-moderate)

ParseHeaders is defined in ObexBase.cpp: 82 ParseHeaders(const uint8_t* aHeaderStart, 83 int aTotalLength, 84 ObexHeaderSet* aRetHandlerSet) aTotalLength is an int type, and as such can obviously go negative. Inside BluetoothOppManager.cpp, ParseHeaders is called several times: 723 ParseHeaders(&aMessage->mData[7], 724 receivedLength - 7, 725 &pktHeaders); ... 731 ParseHeaders(&aMessage->mData[3], 732 receivedLength - 3, 733 &pktHeaders); ... 739 ParseHeaders(&aMessage->mData[3], 740 receivedLength - 3, 741 &pktHeaders); receievedLength is defined on line 697 as an int and is assigned to an mSize [1]: 697 int receivedLength = aMessage->mSize; UnixSocketRawData->mSize is defined as a size_t at [2] Depending on the distro, size_t can be 8-bytes and int can be 4-bytes. Also, size_t is unsigned while int is signed. Therefore, receivedLength has the potential to be negative and ParseHeaders' aTotalLength will also be negative. Currently, all FxOS devices are 32-bit, so *most likely* size_t is also 4-bytes. However, there is still the issue of signed vs. unsigned. [1] http://mxr.mozilla.org/mozilla-central/source/dom/bluetooth/BluetoothOppManager.cpp#697 [2] http://mxr.mozilla.org/mozilla-central/source/ipc/unixsocket/UnixSocket.h#46
probably not an immediate security concern, but we'd like to get Bluetooth working in the FxOS emulators and some of those can be 64 bits.
Group: b2g-core-security
Group: b2g-core-security
Group: core-security → b2g-core-security
FirefoxOS is no longer under active development.
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → INCOMPLETE
Group: b2g-core-security
You need to log in before you can comment on or make changes to this bug.