mirror of
https://github.com/neovim/neovim.git
synced 2026-03-31 12:52:13 +00:00
fix(messages): heap-buffer-overflow with shell command (#37855)
Problem: heap-buffer-overflow when showing output of a shell command. Solution: Use xmemrchr() instead of strrchr(). Ref: https://github.com/neovim/neovim/pull/37831#issuecomment-3900149476
This commit is contained in:
@@ -2354,7 +2354,7 @@ static void msg_puts_display(const char *str, int maxlen, int hl_id, int recurse
|
||||
ga_concat_len(&msg_ext_last_chunk, str, len);
|
||||
|
||||
// Find last newline in the message and calculate the current message column
|
||||
const char *lastline = strrchr(str, '\n');
|
||||
const char *lastline = xmemrchr(str, '\n', len);
|
||||
maxlen -= (int)(lastline ? (lastline - str) : 0);
|
||||
const char *p = lastline ? lastline + 1 : str;
|
||||
int col = (int)(maxlen < 0 ? mb_string2cells(p) : mb_string2cells_len(p, (size_t)(maxlen)));
|
||||
|
||||
Reference in New Issue
Block a user