Skip to content
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

Logging Buffer Overrun Fix #42

Merged
merged 6 commits into from
Feb 26, 2024
Merged

Logging Buffer Overrun Fix #42

merged 6 commits into from
Feb 26, 2024

Conversation

ztnel
Copy link
Contributor

@ztnel ztnel commented Feb 26, 2024

Description

Fix buffer overrun bug in the logger modules string building function. The MAX_LOGGING_LINE_LENGTH macro is now 1 less than the total supported size to accommodate for the null byte delimiter. The string building function was tested for log lines greater than and less than the maximum length set by MAX_LOGGING_LINE_LENGTH

Resolutions

  • Fix buffer overrun in the logger module string building functions
  • Add template .clangd configuration file in utils

Issues

closes #13

@ztnel ztnel added the defect Something isn't working label Feb 26, 2024
@ztnel ztnel self-assigned this Feb 26, 2024
@ztnel ztnel changed the title Buffer Overrun Fix Logging Buffer Overrun Fix Feb 26, 2024
@ztnel ztnel added the firmware embedded software development label Feb 26, 2024
src/logger.c Outdated
@@ -151,8 +150,9 @@ void logger_task(void *pv_params) {
if (client_fd < 0) {
continue;
}
build_log_string(&log);
ssize_t bytes_sent = send(client_fd, &log.message, strlen(log.message), 0);
char buffer[MAX_LOGGING_LINE_LEN];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

char buffer[MAX_LOGGING_LINE_LEN] = {0}
Zero initialization for char buffer array if you want

@ztnel ztnel merged commit d32bf57 into master Feb 26, 2024
2 of 3 checks passed
@ztnel ztnel deleted the logging-fix branch February 26, 2024 03:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect Something isn't working firmware embedded software development
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Log Handling Subsystem
2 participants