Support for IPv6 in HTTP socket and BufferReader unittests
* Add Apple MD5 support in DeviceFiles [ Merge of http://go/wvgerrit/15544 ] Patch courtesy of Spotify. * Changing vague BufferReader log message [ Merge of http://go/wvgerrit/15515 ] Amending the buffer reader log message for null parameters in the read function to say the type of parameter to help tell the difference between Read2, Read2s, Read4, Read4s, Read8, and Read8s. Bug: 23619044 * Fix HTTP socket tests [ Merge of http://go/wvgerrit/15521 ] This fixes the build on Jenkins. I missed these when I updated HTTP socket because they are not part of the CE CDM test suite. * Update HttpSocket for IPv6 [ Merge of http://go/wvgerrit/15517 ] Previously, HttpSocket made assumptions about IPv4. This CL updates this utility to be agnostic to IPv4 vs IPv6. If our servers start resolving to IPv6 addresses in future, our tests can now handle this transparently. * Removed low level warnings from PSSH [ Merge of http://go/wvgerrit/15489 ] Unneeded warnings in parsing PSSH and in buffer reader were appearing in the logs. LOGW commands were replaced with LOGV. Bug: 23419359 * BufferReader unit tests and hardening. [ Merge of http://go/wvgerrit/15449 ] Added unit tests for public-facing functions. Added protection against null or negative parameters. Bug: 23419008 Change-Id: Ia44100a2d1bafe68986ae9a0793214885b21e61e
This commit is contained in:
@@ -7,8 +7,15 @@
|
||||
namespace wvcdm {
|
||||
|
||||
bool BufferReader::Read1(uint8_t* v) {
|
||||
if (v == NULL) {
|
||||
LOGE("BufferReader::Read1 : Failure during parse: Null output parameter "
|
||||
"when expecting non-null");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!HasBytes(1)) {
|
||||
LOGW("BufferReader::Read1 : Failure while parsing: Not enough bytes (1)");
|
||||
LOGV("BufferReader::Read1 : Failure while parsing: "
|
||||
"Not enough bytes (1)");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -19,9 +26,15 @@ bool BufferReader::Read1(uint8_t* v) {
|
||||
// Internal implementation of multi-byte reads
|
||||
template <typename T>
|
||||
bool BufferReader::Read(T* v) {
|
||||
if (v == NULL) {
|
||||
LOGE("BufferReader::Read<T> : Failure during parse: Null output parameter "
|
||||
"when expecting non-null (%s)", __PRETTY_FUNCTION__);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!HasBytes(sizeof(T))) {
|
||||
LOGW("BufferReader::Read<T> : Failure during parse: Not enough bytes (%u)",
|
||||
sizeof(T));
|
||||
LOGV("BufferReader::Read<T> : Failure during parse: "
|
||||
"Not enough bytes (%u)", sizeof(T));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -41,10 +54,16 @@ bool BufferReader::Read4s(int32_t* v) { return Read(v); }
|
||||
bool BufferReader::Read8(uint64_t* v) { return Read(v); }
|
||||
bool BufferReader::Read8s(int64_t* v) { return Read(v); }
|
||||
|
||||
bool BufferReader::ReadString(std::string* str, int count) {
|
||||
bool BufferReader::ReadString(std::string* str, size_t count) {
|
||||
if (str == NULL) {
|
||||
LOGE("BufferReader::ReadString : Failure during parse: Null output "
|
||||
"parameter when expecting non-null");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!HasBytes(count)) {
|
||||
LOGW("BufferReader::ReadString : Parse Failure: Not enough bytes (%d)",
|
||||
count);
|
||||
LOGV("BufferReader::ReadString : Parse Failure: "
|
||||
"Not enough bytes (%d)", count);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -53,9 +72,16 @@ bool BufferReader::ReadString(std::string* str, int count) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BufferReader::ReadVec(std::vector<uint8_t>* vec, int count) {
|
||||
bool BufferReader::ReadVec(std::vector<uint8_t>* vec, size_t count) {
|
||||
if (vec == NULL) {
|
||||
LOGE("BufferReader::ReadVec : Failure during parse: Null output parameter "
|
||||
"when expecting non-null");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!HasBytes(count)) {
|
||||
LOGW("BufferReader::ReadVec : Parse Failure: Not enough bytes (%d)", count);
|
||||
LOGV("BufferReader::ReadVec : Parse Failure: "
|
||||
"Not enough bytes (%d)", count);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -65,10 +91,10 @@ bool BufferReader::ReadVec(std::vector<uint8_t>* vec, int count) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BufferReader::SkipBytes(int bytes) {
|
||||
bool BufferReader::SkipBytes(size_t bytes) {
|
||||
if (!HasBytes(bytes)) {
|
||||
LOGW("BufferReader::SkipBytes : Parse Failure: Not enough bytes (%d)",
|
||||
bytes);
|
||||
LOGV("BufferReader::SkipBytes : Parse Failure: "
|
||||
"Not enough bytes (%d)", bytes);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -77,6 +103,12 @@ bool BufferReader::SkipBytes(int bytes) {
|
||||
}
|
||||
|
||||
bool BufferReader::Read4Into8(uint64_t* v) {
|
||||
if (v == NULL) {
|
||||
LOGE("BufferReader::Read4Into8 : Failure during parse: Null output "
|
||||
"parameter when expecting non-null");
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t tmp;
|
||||
if (!Read4(&tmp)) {
|
||||
return false;
|
||||
@@ -86,6 +118,12 @@ bool BufferReader::Read4Into8(uint64_t* v) {
|
||||
}
|
||||
|
||||
bool BufferReader::Read4sInto8s(int64_t* v) {
|
||||
if (v == NULL) {
|
||||
LOGE("BufferReader::Read4sInto8s : Failure during parse: Null output "
|
||||
"parameter when expecting non-null");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Beware of the need for sign extension.
|
||||
int32_t tmp;
|
||||
if (!Read4s(&tmp)) {
|
||||
@@ -94,5 +132,4 @@ bool BufferReader::Read4sInto8s(int64_t* v) {
|
||||
*v = tmp;
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace wvcdm
|
||||
|
||||
Reference in New Issue
Block a user