diff options
author | Martijn Coenen <maco@google.com> | 2018-12-05 09:42:25 +0100 |
---|---|---|
committer | Martijn Coenen <maco@google.com> | 2018-12-11 11:07:49 +0000 |
commit | c1cea05b5f052474d3df90adbe40f5796d950a6e (patch) | |
tree | ae4a333e8d962c56aa4db9a4adb1fc03138eb585 | |
parent | f546acd3fa45878ac9d98589e1f66f5bce90a24a (diff) | |
download | core-c1cea05b5f052474d3df90adbe40f5796d950a6e.tar.gz core-c1cea05b5f052474d3df90adbe40f5796d950a6e.tar.bz2 core-c1cea05b5f052474d3df90adbe40f5796d950a6e.zip |
Export maximum number of fds/ints in a native_handle.
So we can deserialize it consisently and safely.
Bug: 120084106
Test: builds
Change-Id: I0eafff70d3a7e4d732fe600a0052efb90108208d
Merged-In: I0eafff70d3a7e4d732fe600a0052efb90108208d
-rw-r--r-- | libcutils/include/cutils/native_handle.h | 3 | ||||
-rw-r--r-- | libcutils/native_handle.c | 6 |
2 files changed, 5 insertions, 4 deletions
diff --git a/libcutils/include/cutils/native_handle.h b/libcutils/include/cutils/native_handle.h index 7d6a98802..5696edb97 100644 --- a/libcutils/include/cutils/native_handle.h +++ b/libcutils/include/cutils/native_handle.h @@ -23,6 +23,9 @@ extern "C" { #endif +#define NATIVE_HANDLE_MAX_FDS 1024 +#define NATIVE_HANDLE_MAX_INTS 1024 + /* Declare a char array for use with native_handle_init */ #define NATIVE_HANDLE_DECLARE_STORAGE(name, maxFds, maxInts) \ alignas(native_handle_t) char name[ \ diff --git a/libcutils/native_handle.c b/libcutils/native_handle.c index 9f4840a59..2a092dce8 100644 --- a/libcutils/native_handle.c +++ b/libcutils/native_handle.c @@ -25,9 +25,6 @@ #include <android/log.h> #include <cutils/native_handle.h> -static const int kMaxNativeFds = 1024; -static const int kMaxNativeInts = 1024; - native_handle_t* native_handle_init(char* storage, int numFds, int numInts) { if ((uintptr_t) storage % alignof(native_handle_t)) { @@ -44,7 +41,8 @@ native_handle_t* native_handle_init(char* storage, int numFds, int numInts) native_handle_t* native_handle_create(int numFds, int numInts) { - if (numFds < 0 || numInts < 0 || numFds > kMaxNativeFds || numInts > kMaxNativeInts) { + if (numFds < 0 || numInts < 0 || numFds > NATIVE_HANDLE_MAX_FDS || + numInts > NATIVE_HANDLE_MAX_INTS) { return NULL; } |