Skip to content

Commit

Permalink
[nrf fromlist] log: Fix defining CONFIG_LOG_STRDUP_MAX_STRING
Browse files Browse the repository at this point in the history
Upstream PR: zephyrproject-rtos/zephyr#33248

Change fixes an issue related to data access out of array bounds and
suppresses compiler warning.

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
  • Loading branch information
MarekPieta authored and anangl committed Mar 23, 2021
1 parent 9f56e26 commit ad2dbe9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions subsys/logging/Kconfig.processing
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ config LOG_DETECT_MISSED_STRDUP

config LOG_STRDUP_MAX_STRING
int "Longest string that can be duplicated using log_strdup()"
range 1 8192
default 66 if BT
default 46 if NETWORKING
default 32
Expand Down
5 changes: 4 additions & 1 deletion subsys/logging/log_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ LOG_MODULE_REGISTER(log);
#endif

#ifndef CONFIG_LOG_STRDUP_MAX_STRING
#define CONFIG_LOG_STRDUP_MAX_STRING 0
/* Required to suppress compiler warnings related to array subscript above array bounds.
* log_strdup explicitly accesses element with index of (sizeof(log_strdup_buf.buf) - 2).
*/
#define CONFIG_LOG_STRDUP_MAX_STRING 1
#endif

#ifndef CONFIG_LOG_STRDUP_BUF_COUNT
Expand Down

0 comments on commit ad2dbe9

Please sign in to comment.