<feed xmlns='http://www.w3.org/2005/Atom'>
<title>rneovim.git/test/old/testdir/crash/vim_msg_trunc_poc, branch rahm</title>
<subtitle>Neovim fork with Rahm's personal hacks.
</subtitle>
<link rel='alternate' type='text/html' href='https://git.josher.dev/cgit/rneovim.git/'/>
<entry>
<title>vim-patch:9.0.1969: [security] buffer-overflow in trunc_string()</title>
<updated>2023-11-17T01:59:16+00:00</updated>
<author>
<name>zeertzjq</name>
<email>zeertzjq@outlook.com</email>
</author>
<published>2023-11-17T01:33:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.josher.dev/cgit/rneovim.git/commit/?id=3ab0e296c674a6846512df24a0a70199bba8c59a'/>
<id>3ab0e296c674a6846512df24a0a70199bba8c59a</id>
<content type='text'>
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 &lt; 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.

https://github.com/vim/vim/commit/3bd7fa12e146c6051490d048a4acbfba974eeb04

vim-patch:9.0.2004: Missing test file

Problem:  Missing test file
Solution: git-add the file to the repo

closes: vim/vim#13305

https://github.com/vim/vim/commit/d4afbdd0715c722cfc73d3a8ab9e578667615faa

Co-authored-by: Christian Brabandt &lt;cb@256bit.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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 &lt; 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.

https://github.com/vim/vim/commit/3bd7fa12e146c6051490d048a4acbfba974eeb04

vim-patch:9.0.2004: Missing test file

Problem:  Missing test file
Solution: git-add the file to the repo

closes: vim/vim#13305

https://github.com/vim/vim/commit/d4afbdd0715c722cfc73d3a8ab9e578667615faa

Co-authored-by: Christian Brabandt &lt;cb@256bit.org&gt;
</pre>
</div>
</content>
</entry>
</feed>
