Skip to content

out of bounds access in log_backend_rtt #14536

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
galak opened this issue Mar 14, 2019 · 0 comments
Closed

out of bounds access in log_backend_rtt #14536

galak opened this issue Mar 14, 2019 · 0 comments
Assignees
Labels
area: Logging bug The issue is a bug, or the PR is fixing a bug priority: medium Medium impact/importance bug

Comments

@galak
Copy link
Collaborator

galak commented Mar 14, 2019

When building with clang we get these warnings, which seem like a real possible issue. Seems like we might need some ifdef protection.

This was seen building:

-p nrf52840_pca10056 -T samples/basic/fade_led

/home/galak/git/zephyr/subsys/logging/log_backend_rtt.c:116:4: error: array index -2 is before the beginning of the array [-Werror,-Warray-bounds]
                        line_buf[DROP_MSG_LEN - 2] = ' ';
                        ^        ~~~~~~~~~~~~~~~~
/home/galak/git/zephyr/subsys/logging/log_backend_rtt.c:49:1: note: array 'line_buf' declared here
static u8_t line_buf[MESSAGE_SIZE + DROP_MSG_LEN];
^
/home/galak/git/zephyr/subsys/logging/log_backend_rtt.c:117:4: error: array index -3 is before the beginning of the array [-Werror,-Warray-bounds]
                        line_buf[DROP_MSG_LEN - 3] = (u8_t) ('0' + cnt);
                        ^        ~~~~~~~~~~~~~~~~
/home/galak/git/zephyr/subsys/logging/log_backend_rtt.c:49:1: note: array 'line_buf' declared here
static u8_t line_buf[MESSAGE_SIZE + DROP_MSG_LEN];
^
/home/galak/git/zephyr/subsys/logging/log_backend_rtt.c:118:4: error: array index -4 is before the beginning of the array [-Werror,-Warray-bounds]
                        line_buf[DROP_MSG_LEN - 4] = ' ';
                        ^        ~~~~~~~~~~~~~~~~
/home/galak/git/zephyr/subsys/logging/log_backend_rtt.c:49:1: note: array 'line_buf' declared here
static u8_t line_buf[MESSAGE_SIZE + DROP_MSG_LEN];
^
/home/galak/git/zephyr/subsys/logging/log_backend_rtt.c:120:4: error: array index -2 is before the beginning of the array [-Werror,-Warray-bounds]
                        line_buf[DROP_MSG_LEN - 2] = (u8_t) ('0' + cnt % 10);
                        ^        ~~~~~~~~~~~~~~~~
/home/galak/git/zephyr/subsys/logging/log_backend_rtt.c:49:1: note: array 'line_buf' declared here
static u8_t line_buf[MESSAGE_SIZE + DROP_MSG_LEN];
^
/home/galak/git/zephyr/subsys/logging/log_backend_rtt.c:121:4: error: array index -3 is before the beginning of the array [-Werror,-Warray-bounds]
                        line_buf[DROP_MSG_LEN - 3] = (u8_t) ('0' + cnt / 10);
                        ^        ~~~~~~~~~~~~~~~~
/home/galak/git/zephyr/subsys/logging/log_backend_rtt.c:49:1: note: array 'line_buf' declared here
static u8_t line_buf[MESSAGE_SIZE + DROP_MSG_LEN];
^
/home/galak/git/zephyr/subsys/logging/log_backend_rtt.c:122:4: error: array index -4 is before the beginning of the array [-Werror,-Warray-bounds]
                        line_buf[DROP_MSG_LEN - 4] = '>';
                        ^        ~~~~~~~~~~~~~~~~
/home/galak/git/zephyr/subsys/logging/log_backend_rtt.c:49:1: note: array 'line_buf' declared here
static u8_t line_buf[MESSAGE_SIZE + DROP_MSG_LEN];
^
6 errors generated.
make[3]: *** [zephyr/CMakeFiles/zephyr.dir/build.make:414: zephyr/CMakeFiles/zephyr.dir/subsys/logging/log_backend_rtt.c.obj] Error 1
@galak galak added bug The issue is a bug, or the PR is fixing a bug area: Logging labels Mar 14, 2019
@galak galak added the priority: medium Medium impact/importance bug label Mar 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Logging bug The issue is a bug, or the PR is fixing a bug priority: medium Medium impact/importance bug
Projects
None yet
Development

No branches or pull requests

2 participants