diff --git a/components/bt/host/bluedroid/stack/goep/goepc_api.c b/components/bt/host/bluedroid/stack/goep/goepc_api.c index 60badbaeec..06be8f59cb 100644 --- a/components/bt/host/bluedroid/stack/goep/goepc_api.c +++ b/components/bt/host/bluedroid/stack/goep/goepc_api.c @@ -359,7 +359,7 @@ UINT16 GOEPC_RequestAddHeader(UINT16 handle, UINT8 header_id, const UINT8 *data, break; } - if (data == NULL || data_len == 0) { + if ((data == NULL && data_len != 0) || (data != NULL && data_len == 0)) { ret = GOEP_INVALID_PARAM; break; } diff --git a/components/bt/host/bluedroid/stack/obex/obex_api.c b/components/bt/host/bluedroid/stack/obex/obex_api.c index ab224ce78c..b9df8eb4ae 100644 --- a/components/bt/host/bluedroid/stack/obex/obex_api.c +++ b/components/bt/host/bluedroid/stack/obex/obex_api.c @@ -481,7 +481,11 @@ UINT16 OBEX_AppendHeader(BT_HDR *pkt, const UINT8 *header) *******************************************************************************/ UINT16 OBEX_AppendHeaderRaw(BT_HDR *pkt, UINT8 header_id, const UINT8 *data, UINT16 data_len) { - if (pkt == NULL || data == NULL) { + if (pkt == NULL) { + return OBEX_INVALID_PARAM; + } + + if ((data == NULL && data_len != 0) || (data != NULL && data_len == 0)) { return OBEX_INVALID_PARAM; } @@ -527,8 +531,10 @@ UINT16 OBEX_AppendHeaderRaw(BT_HDR *pkt, UINT8 header_id, const UINT8 *data, UIN UINT16_TO_BE_FIELD(p_start, header_len); p_start+= 2; } - /* store data */ - memcpy(p_start, data, data_len); + if (data != NULL) { + /* store data */ + memcpy(p_start, data, data_len); + } pkt->len += header_len; /* point to packet len */ p_data++;