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

hardfault_log: fix NULL terminator truncation #12284

Merged
merged 1 commit into from
Jun 17, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/systemcmds/hardfault_log/hardfault_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ static int format_fault_file_name(struct timespec *ts, char *buffer, unsigned in
unsigned int plen = LOG_PATH_BASE_LEN;

if (maxsz >= LOG_PATH_LEN) {
strncpy(buffer, LOG_PATH_BASE, plen);
memcpy(buffer, LOG_PATH_BASE, plen);
maxsz -= plen;
int rv = format_fault_time(TIME_FMT, ts, fmtbuff, arraySize(fmtbuff));

Expand Down Expand Up @@ -312,7 +312,7 @@ static int write_stack(bool inValid, int winsize, uint32_t wtopaddr,
if (wtopaddr == topaddr) {
strncpy(marker, "<-- ", sizeof(marker));
strncat(marker, sp_name, sizeof(marker) - 1);
strncat(marker, " top", sizeof(marker));
strncat(marker, " top", sizeof(marker) - 1);

} else if (wtopaddr == spaddr) {
strncpy(marker, "<-- ", sizeof(marker));
Expand All @@ -321,7 +321,7 @@ static int write_stack(bool inValid, int winsize, uint32_t wtopaddr,
} else if (wtopaddr == botaddr) {
strncpy(marker, "<-- ", sizeof(marker));
strncat(marker, sp_name, sizeof(marker) - 1);
strncat(marker, " bottom", sizeof(marker));
strncat(marker, " bottom", sizeof(marker) - 1);

} else {
marker[0] = '\0';
Expand Down