Mercurial > vim
comparison src/ex_docmd.c @ 29083:3de91964bbd6 v8.2.5063
patch 8.2.5063: error for a command may go over the end of IObuff
Commit: https://github.com/vim/vim/commit/44a3f3353e0407e9fffee138125a6927d1c9e7e5
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jun 6 15:38:21 2022 +0100
patch 8.2.5063: error for a command may go over the end of IObuff
Problem: Error for a command may go over the end of IObuff.
Solution: Truncate the message.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 06 Jun 2022 16:45:03 +0200 |
parents | f79cff615e69 |
children | c7a8d4bf4d04 |
comparison
equal
deleted
inserted
replaced
29082:c009a9830f56 | 29083:3de91964bbd6 |
---|---|
3439 * invisible otherwise. | 3439 * invisible otherwise. |
3440 */ | 3440 */ |
3441 static void | 3441 static void |
3442 append_command(char_u *cmd) | 3442 append_command(char_u *cmd) |
3443 { | 3443 { |
3444 char_u *s = cmd; | 3444 size_t len = STRLEN(IObuff); |
3445 char_u *d; | 3445 char_u *s = cmd; |
3446 | 3446 char_u *d; |
3447 | |
3448 if (len > IOSIZE - 100) | |
3449 { | |
3450 // Not enough space, truncate and put in "...". | |
3451 d = IObuff + IOSIZE - 100; | |
3452 d -= mb_head_off(IObuff, d); | |
3453 STRCPY(d, "..."); | |
3454 } | |
3447 STRCAT(IObuff, ": "); | 3455 STRCAT(IObuff, ": "); |
3448 d = IObuff + STRLEN(IObuff); | 3456 d = IObuff + STRLEN(IObuff); |
3449 while (*s != NUL && d - IObuff + 5 < IOSIZE) | 3457 while (*s != NUL && d - IObuff + 5 < IOSIZE) |
3450 { | 3458 { |
3451 if (enc_utf8 ? (s[0] == 0xc2 && s[1] == 0xa0) : *s == 0xa0) | 3459 if (enc_utf8 ? (s[0] == 0xc2 && s[1] == 0xa0) : *s == 0xa0) |