am 1def25a2: Merge commit \'7ac60686\' into manualmerge
* commit '1def25a210ca502a97020efb732775d5c2df2d9a': Prevent integer overflow when allocating native_handle_t
This commit is contained in:
commit
4e83064190
1 changed files with 8 additions and 2 deletions
|
|
@ -25,11 +25,17 @@
|
||||||
#include <cutils/log.h>
|
#include <cutils/log.h>
|
||||||
#include <cutils/native_handle.h>
|
#include <cutils/native_handle.h>
|
||||||
|
|
||||||
|
static const int kMaxNativeFds = 1024;
|
||||||
|
static const int kMaxNativeInts = 1024;
|
||||||
|
|
||||||
native_handle_t* native_handle_create(int numFds, int numInts)
|
native_handle_t* native_handle_create(int numFds, int numInts)
|
||||||
{
|
{
|
||||||
native_handle_t* h = malloc(
|
if (numFds < 0 || numInts < 0 || numFds > kMaxNativeFds || numInts > kMaxNativeInts) {
|
||||||
sizeof(native_handle_t) + sizeof(int)*(numFds+numInts));
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t mallocSize = sizeof(native_handle_t) + (sizeof(int) * (numFds + numInts));
|
||||||
|
native_handle_t* h = malloc(mallocSize);
|
||||||
if (h) {
|
if (h) {
|
||||||
h->version = sizeof(native_handle_t);
|
h->version = sizeof(native_handle_t);
|
||||||
h->numFds = numFds;
|
h->numFds = numFds;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue