Bug 1236561 - part 2 - remove ObexHeaderSet::GetAuthChallenge; r=btian

We don't need to copy data in this case, and making this change enables
us to remove this use of nsAutoArrayPtr.
This commit is contained in:
Nathan Froyd 2015-12-06 10:28:04 -05:00
parent 3c8e039985
commit 4a4e2a5363
2 changed files with 5 additions and 22 deletions

View File

@ -517,9 +517,7 @@ BluetoothPbapManager::NotifyPasswordRequest(const ObexHeaderSet& aHeader)
MOZ_ASSERT(aHeader.Has(ObexHeaderId::AuthChallenge));
// Get authentication challenge data
int dataLength;
nsAutoArrayPtr<uint8_t> dataPtr;
aHeader.GetAuthChallenge(dataPtr, &dataLength);
const ObexHeader* authHeader = aHeader.GetHeader(ObexHeaderId::AuthChallenge);
// Get nonce from authentication challenge
// Section 3.5.1 "Digest Challenge", IrOBEX spec 1.2
@ -527,16 +525,16 @@ BluetoothPbapManager::NotifyPasswordRequest(const ObexHeaderSet& aHeader)
// [tagId:1][length:1][nonce:16]
uint8_t offset = 0;
do {
uint8_t tagId = dataPtr[offset++];
uint8_t length = dataPtr[offset++];
uint8_t tagId = authHeader->mData[offset++];
uint8_t length = authHeader->mData[offset++];
BT_LOGR("AuthChallenge header includes tagId %d", tagId);
if (tagId == ObexDigestChallenge::Nonce) {
memcpy(mRemoteNonce, &dataPtr[offset], DIGEST_LENGTH);
memcpy(mRemoteNonce, &authHeader->mData[offset], DIGEST_LENGTH);
}
offset += length;
} while (offset < dataLength);
} while (offset < authHeader->mDataLength);
// Ensure bluetooth service is available
BluetoothService* bs = BluetoothService::Get();

View File

@ -248,21 +248,6 @@ public:
}
}
void GetAuthChallenge(nsAutoArrayPtr<uint8_t>& aRetData,
int* aRetDataLength) const
{
*aRetDataLength = 0;
for (uint8_t i = 0; i < mHeaders.Length(); ++i) {
if (mHeaders[i]->mId == ObexHeaderId::AuthChallenge) {
aRetData = new uint8_t[mHeaders[i]->mDataLength];
memcpy(aRetData, mHeaders[i]->mData, mHeaders[i]->mDataLength);
*aRetDataLength = mHeaders[i]->mDataLength;
return;
}
}
}
uint32_t GetConnectionId() const
{
int length = mHeaders.Length();