mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-26 17:37:34 +00:00
u/logging: Use truncating snprintf utility for JSON log
When using the JSON logging mode, truncate log strings to ensure they fit in the allocated message buffer Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2373>
This commit is contained in:
parent
efa6c5d149
commit
e076de071a
|
@ -339,7 +339,7 @@ log_as_json(const char *file, const char *func, enum u_logging_level level, cons
|
|||
|
||||
// Add message.
|
||||
char msg_buf[LOG_BUFFER_SIZE];
|
||||
vsprintf(msg_buf, format, args);
|
||||
u_truncate_vsnprintf(msg_buf, LOG_BUFFER_SIZE, format, args);
|
||||
cJSON_AddItemToObject(root, "message", cJSON_CreateString(msg_buf));
|
||||
|
||||
// Get string and print to stderr.
|
||||
|
|
Loading…
Reference in a new issue