diff options
author | Marie Janssen <jamuraa@google.com> | 2016-05-12 15:30:16 -0700 |
---|---|---|
committer | The Android Automerger <android-build@google.com> | 2016-05-26 15:17:12 -0700 |
commit | 5b9f286d7fc54862c0c553181f7aa3e1465e2af1 (patch) | |
tree | c91c89b9bf9055bdb21c23b8d3336403a4afea61 | |
parent | 203d389d935f038a1194ff00e9fb2bd8d03d029e (diff) | |
download | bluedroid-5b9f286d7fc54862c0c553181f7aa3e1465e2af1.tar.gz |
DO NOT MERGE btif: check overflow on create_pbuf size
Bug: 27930580
Change-Id: Ieb1f23f9a8a937b21f7c5eca92da3b0b821400e6
-rw-r--r-- | btif/src/btif_hh.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/btif/src/btif_hh.c b/btif/src/btif_hh.c index 99b0840..7c94e87 100644 --- a/btif/src/btif_hh.c +++ b/btif/src/btif_hh.c @@ -33,6 +33,8 @@ #define LOG_TAG "BTIF_HH" +#include <cutils/log.h> + #include "bta_api.h" #include "bta_hh_api.h" #include "bd.h" @@ -256,7 +258,12 @@ static void toggle_os_keylockstates(int fd, int changedlockstates) *******************************************************************************/ static BT_HDR *create_pbuf(UINT16 len, UINT8 *data) { - BT_HDR* p_buf = GKI_getbuf((UINT16) (len + BTA_HH_MIN_OFFSET + sizeof(BT_HDR))); + UINT16 buflen = (UINT16) (len + BTA_HH_MIN_OFFSET + sizeof(BT_HDR)); + if (buflen < len) { + android_errorWriteWithInfoLog(0x534e4554, "28672558", -1, NULL, 0); + return NULL; + } + BT_HDR* p_buf = GKI_getbuf(buflen); if (p_buf) { UINT8* pbuf_data; |