Mercurial > vim
annotate src/gui_haiku.h @ 33422:25d250a74bb6 v9.0.1969
patch 9.0.1969: [security] buffer-overflow in trunc_string()
Commit: https://github.com/vim/vim/commit/3bd7fa12e146c6051490d048a4acbfba974eeb04
Author: Christian Brabandt <cb@256bit.org>
Date: Mon Oct 2 20:59:08 2023 +0200
patch 9.0.1969: [security] buffer-overflow in trunc_string()
Problem: buffer-overflow in trunc_string()
Solution: Add NULL at end of buffer
Currently trunc_string() assumes that when the string is too long,
buf[e-1] will always be writeable. But that assumption may not always be
true. The condition currently looks like this
else if (e + 3 < buflen)
[...]
else
{
// can't fit in the "...", just truncate it
buf[e - 1] = NUL;
}
but this means, we may run into the last else clause with e still being
larger than buflen. So a buffer overflow occurs.
So instead of using `buf[e - 1]`, let's just always
truncate at `buf[buflen - 1]` which should always be writable.
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Mon, 02 Oct 2023 21:30:04 +0200 |
parents | 22f0dda71638 |
children |
rev | line source |
---|---|
19526 | 1 /* vi:set ts=8 sts=4 sw=4: |
2 * | |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * GUI support by Olaf "Rhialto" Seibert | |
5 * | |
6 * Do ":help uganda" in Vim to read copying and usage conditions. | |
7 * Do ":help credits" in Vim to see a list of people who contributed. | |
8 * | |
9 * Haiku GUI. | |
10 * | |
11 * Based on "GUI support for the Buzzword Enhanced Operating System for PPC." | |
12 * | |
13 */ | |
14 | |
15 /* | |
16 * This file must be acceptable both as C and C++. | |
17 * The BeOS API is defined in terms of C++, but some classes | |
18 * should be somewhat known in the common C code. | |
19 */ | |
20 | |
21 // System classes | |
22 | |
23 struct BMenu; | |
24 struct BMenuItem; | |
25 struct BPictureButton; | |
26 | |
27 // Our own Vim-related classes | |
28 | |
29 struct VimApp; | |
30 struct VimFormView; | |
31 struct VimTextAreaView; | |
32 struct VimWindow; | |
33 struct VimScrollBar; | |
34 | |
35 // Locking functions | |
36 | |
37 extern int vim_lock_screen(); | |
38 extern void vim_unlock_screen(); | |
39 | |
40 #ifndef __cplusplus | |
41 | |
42 typedef struct BMenu BMenu; | |
43 typedef struct BMenuItem BMenuItem; | |
44 typedef struct BPictureButton BPictureButton; | |
45 typedef struct VimWindow VimWindow; | |
46 typedef struct VimFormView VimFormView; | |
47 typedef struct VimTextAreaView VimTextAreaView; | |
48 typedef struct VimApp VimApp; | |
49 typedef struct VimScrollBar VimScrollBar; | |
50 | |
51 #endif |