GPU: Fix out of bound write when logging system paths #120967

Merged
Jeroen Bakker merged 2 commits from Jeroen-Bakker/blender:gpu/increase-filename-buffer into main 2024-04-23 12:51:02 +02:00
1 changed files with 2 additions and 2 deletions

View File

@ -210,8 +210,8 @@ void Shader::print_log(Span<const char *> sources,
}
/* Print the filename the error line is coming from. */
if (!log_item.cursor.file_name_and_error_line.is_empty()) {
char name_buf[128];
log_item.cursor.file_name_and_error_line.copy(name_buf);
char name_buf[256];
log_item.cursor.file_name_and_error_line.substr(0, sizeof(name_buf) - 1).copy(name_buf);
Jeroen-Bakker marked this conversation as resolved Outdated

While I'm ok with making name_buf bigger, I think it is better make this line safe.
Use log_item.cursor.file_name_and_error_line.substr(0, sizeof(name_buf) - 1).copy(name_buf);.

While I'm ok with making `name_buf` bigger, I think it is better make this line safe. Use `log_item.cursor.file_name_and_error_line.substr(0, sizeof(name_buf) - 1).copy(name_buf);`.
BLI_dynstr_appendf(dynstr, "%s%s: %s", info_col, name_buf, reset_col);
}
else if (source_index > 0) {