logging: the 'log backend' shell cmd will result in the infinite loop.
The backend_name_get() function always sets 'entry->syntax' to the name of the last backend, but a calling function iterates over the idx until 'entry->syntax' is null. Solution: Added a check that the index is less than the number of backends and added getting the name of the backend by the given index. Signed-off-by: Mikhail Siomin <victorovich.01@mail.ru>
This commit is contained in:
parent
0c0d73721e
commit
b608ddc40f
1 changed files with 9 additions and 1 deletions
|
|
@ -399,12 +399,20 @@ SHELL_STATIC_SUBCMD_SET_CREATE(sub_log_backend,
|
|||
|
||||
static void backend_name_get(size_t idx, struct shell_static_entry *entry)
|
||||
{
|
||||
uint32_t section_count = 0;
|
||||
|
||||
entry->handler = NULL;
|
||||
entry->help = NULL;
|
||||
entry->subcmd = &sub_log_backend;
|
||||
entry->syntax = NULL;
|
||||
|
||||
STRUCT_SECTION_FOREACH(log_backend, backend) {
|
||||
STRUCT_SECTION_COUNT(log_backend, §ion_count);
|
||||
|
||||
if (idx < section_count) {
|
||||
struct log_backend *backend = NULL;
|
||||
|
||||
STRUCT_SECTION_GET(log_backend, idx, &backend);
|
||||
__ASSERT_NO_MSG(backend != NULL);
|
||||
entry->syntax = backend->name;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue