mirror of
https://github.com/schoebel/mars
synced 2024-12-23 07:03:09 +00:00
infra: fix potential fault
Very old idiotic bug. Under some circumstances, a byte beyond the end of a non-null-terminated string (such as produced by the VFS) might be read, potentially leading to a page fault just one byte after a page border.
This commit is contained in:
parent
25d954051b
commit
d18c60f232
@ -152,7 +152,7 @@ extern void _brick_mem_free(void *data, int line);
|
||||
char *_res_ = _brick_string_alloc((_len_) + 1, __LINE__); \
|
||||
_res_ = brick_mark_nonnull(_res_); \
|
||||
if (_res_) { \
|
||||
strncpy(_res_, (_orig_), (_len_) + 1); \
|
||||
strncpy(_res_, (_orig_), (_len_)); \
|
||||
/* always null-terminate for safety */ \
|
||||
_res_[_len_] = '\0'; \
|
||||
} \
|
||||
|
Loading…
Reference in New Issue
Block a user