Skip to content

Commit

Permalink
HDCP: buffer over flow check -- DO NOT MERGE
Browse files Browse the repository at this point in the history
bug: 20222489
Change-Id: I3a64a5999d68ea243d187f12ec7717b7f26d93a3
(cherry picked from commit 532cd7b)
  • Loading branch information
Chong Zhang authored and ciwrl committed Aug 12, 2015
1 parent 7f4cec9 commit 626ad26
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions media/libmedia/IHDCP.cpp
Expand Up @@ -241,8 +241,19 @@ status_t BnHDCP::onTransact(
case HDCP_ENCRYPT:
{
size_t size = data.readInt32();
size_t bufSize = 2 * size;

// watch out for overflow
void *inData = NULL;
if (bufSize > size) {
inData = malloc(bufSize);
}

if (inData == NULL) {
reply->writeInt32(ERROR_OUT_OF_RANGE);
return OK;
}

void *inData = malloc(2 * size);
void *outData = (uint8_t *)inData + size;

data.read(inData, size);
Expand Down Expand Up @@ -295,8 +306,19 @@ status_t BnHDCP::onTransact(
case HDCP_DECRYPT:
{
size_t size = data.readInt32();
size_t bufSize = 2 * size;

// watch out for overflow
void *inData = NULL;
if (bufSize > size) {
inData = malloc(bufSize);
}

if (inData == NULL) {
reply->writeInt32(ERROR_OUT_OF_RANGE);
return OK;
}

void *inData = malloc(2 * size);
void *outData = (uint8_t *)inData + size;

data.read(inData, size);
Expand Down

0 comments on commit 626ad26

Please sign in to comment.