#include <string.h>
#include <unistd.h>
+#include <cutils/log.h>
+
#include "bta_api.h"
#include "btif_common.h"
#include "btif_storage.h"
*******************************************************************************/
static BT_HDR *create_pbuf(UINT16 len, UINT8 *data)
{
- BT_HDR* p_buf = osi_malloc(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 = osi_malloc(buflen);
UINT8* pbuf_data;
p_buf->len = len;