mirror of
https://github.com/espressif/esp-idf.git
synced 2025-10-02 10:00:57 +02:00
Merge branch 'bugfix/fix_bt_coverity_v5.1' into 'release/v5.1'
bugfix: Fix array compared against 0 in btc_manage.c and the issue of uninitialized pointer reading in coexist_printf (v5.1) See merge request espressif/esp-idf!42077
This commit is contained in:
@@ -8,16 +8,17 @@
|
|||||||
#include "btc/btc_task.h"
|
#include "btc/btc_task.h"
|
||||||
#include "osi/thread.h"
|
#include "osi/thread.h"
|
||||||
|
|
||||||
#if BTC_DYNAMIC_MEMORY == FALSE
|
#if BTC_DYNAMIC_MEMORY == TRUE
|
||||||
void *btc_profile_cb_tab[BTC_PID_NUM] = {};
|
|
||||||
#else
|
|
||||||
void **btc_profile_cb_tab;
|
void **btc_profile_cb_tab;
|
||||||
|
#else
|
||||||
|
void *btc_profile_cb_tab[BTC_PID_NUM] = {};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void esp_profile_cb_reset(void)
|
void esp_profile_cb_reset(void)
|
||||||
{
|
{
|
||||||
#if BTC_DYNAMIC_MEMORY == TRUE
|
#if BTC_DYNAMIC_MEMORY == TRUE
|
||||||
if (btc_profile_cb_tab == NULL) {
|
void *p = btc_profile_cb_tab;
|
||||||
|
if (p == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -32,7 +33,8 @@ void esp_profile_cb_reset(void)
|
|||||||
int btc_profile_cb_set(btc_pid_t profile_id, void *cb)
|
int btc_profile_cb_set(btc_pid_t profile_id, void *cb)
|
||||||
{
|
{
|
||||||
#if BTC_DYNAMIC_MEMORY == TRUE
|
#if BTC_DYNAMIC_MEMORY == TRUE
|
||||||
if (btc_profile_cb_tab == NULL) {
|
void *p = btc_profile_cb_tab;
|
||||||
|
if (p == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -49,7 +51,8 @@ int btc_profile_cb_set(btc_pid_t profile_id, void *cb)
|
|||||||
void *btc_profile_cb_get(btc_pid_t profile_id)
|
void *btc_profile_cb_get(btc_pid_t profile_id)
|
||||||
{
|
{
|
||||||
#if BTC_DYNAMIC_MEMORY == TRUE
|
#if BTC_DYNAMIC_MEMORY == TRUE
|
||||||
if (btc_profile_cb_tab == NULL) {
|
void *p = btc_profile_cb_tab;
|
||||||
|
if (p == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
52
components/esp_coex/src/lib_printf.c
Normal file
52
components/esp_coex/src/lib_printf.c
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2016-2025 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file lib_printf.c
|
||||||
|
*
|
||||||
|
* This file contains library-specific printf functions
|
||||||
|
* used by WiFi libraries in the `lib` directory.
|
||||||
|
* These function are used to catch any output which gets printed
|
||||||
|
* by libraries, and redirect it to ESP_LOG macros.
|
||||||
|
*
|
||||||
|
* Eventually WiFi libraries will use ESP_LOG functions internally
|
||||||
|
* and these definitions will be removed.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "esp_log.h"
|
||||||
|
#include "esp_attr.h"
|
||||||
|
|
||||||
|
#define VPRINTF_STACK_BUFFER_SIZE 80
|
||||||
|
|
||||||
|
static int lib_printf(const char* tag, const char* format, va_list arg)
|
||||||
|
{
|
||||||
|
char temp[VPRINTF_STACK_BUFFER_SIZE];
|
||||||
|
int len = vsnprintf(temp, sizeof(temp) - 1, format, arg);
|
||||||
|
temp[sizeof(temp) - 1] = 0;
|
||||||
|
int i;
|
||||||
|
for (i = len - 1; i >= 0; --i) {
|
||||||
|
if (temp[i] != '\n' && temp[i] != '\r' && temp[i] != ' ') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
temp[i] = 0;
|
||||||
|
}
|
||||||
|
if (i > 0) {
|
||||||
|
ESP_LOGI(tag, "%s", temp);
|
||||||
|
}
|
||||||
|
va_end(arg);
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
int coexist_printf(const char* format, ...)
|
||||||
|
{
|
||||||
|
va_list arg = {};
|
||||||
|
va_start(arg, format);
|
||||||
|
int res = lib_printf("coexist", format, arg);
|
||||||
|
va_end(arg);
|
||||||
|
return res;
|
||||||
|
}
|
Reference in New Issue
Block a user