Skip to content
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
11 changes: 6 additions & 5 deletions src/status.c
Original file line number Diff line number Diff line change
Expand Up @@ -672,11 +672,12 @@
char escaped[STATUS_LOG_ENTRY_LEN * 2];
json_escape_string(status_shared->log_entries[log_idx].message, escaped, sizeof(escaped));

len += snprintf(buffer + len, buffer_capacity - (size_t)len,
"{\"timestamp\":%ld,\"level\":%d,\"levelName\":\"%s\",\"message\":\"%"
"s\"}",
(long)status_shared->log_entries[log_idx].timestamp, status_shared->log_entries[log_idx].level,
status_get_log_level_name(status_shared->log_entries[log_idx].level), escaped);
len +=
snprintf(buffer + len, buffer_capacity - (size_t)len,

Check failure

Code scanning / CodeQL

Potentially overflowing call to snprintf High

The
size argument
of this snprintf call is derived from its return value, which may exceed the size of the buffer and overflow.
"{\"timestamp\":%lld,\"level\":%d,\"levelName\":\"%s\",\"message\":\"%"
"s\"}",
(long long)status_shared->log_entries[log_idx].timestamp, status_shared->log_entries[log_idx].level,
status_get_log_level_name(status_shared->log_entries[log_idx].level), escaped);
}
last_write_index = cur_wi;
last_log_count = cur_count;
Expand Down
Loading