diff options
author | nfnty <git@nfnty.se> | 2016-12-11 23:44:54 +0100 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2017-01-05 15:17:34 +0100 |
commit | 7a344c795f30bc45adb3973931dbedbdfed7e67c (patch) | |
tree | bf04ad388426c8c5672964e859489a9bdbb10a4b /test/unit/path_spec.lua | |
parent | 12b50b116f305dcc454a594fa25a5e9934b48d01 (diff) | |
download | rneovim-7a344c795f30bc45adb3973931dbedbdfed7e67c.tar.gz rneovim-7a344c795f30bc45adb3973931dbedbdfed7e67c.tar.bz2 rneovim-7a344c795f30bc45adb3973931dbedbdfed7e67c.zip |
path.c: `vim_FullName()`: Fix heap overflow #5737
- Clarify documentation.
- Return `FAIL` and truncate if `fname` is too long.
- Add tests.
Diffstat (limited to 'test/unit/path_spec.lua')
-rw-r--r-- | test/unit/path_spec.lua | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/unit/path_spec.lua b/test/unit/path_spec.lua index 9b76834383..ccaf0228ab 100644 --- a/test/unit/path_spec.lua +++ b/test/unit/path_spec.lua @@ -336,6 +336,17 @@ describe('more path function', function() eq(FAIL, result) end) + it('fails safely if given length is wrong #5737', function() + local force_expansion = 1 + local filename = 'foo/bar/bazzzzzzz/buz/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/a' + local too_short_len = 8 + local buf = cstr(too_short_len, '') + local result = path.vim_FullName(filename, buf, too_short_len, force_expansion) + local expected = string.sub(filename, 1, (too_short_len - 1)) + eq(expected, (ffi.string(buf))) + eq(FAIL, result) + end) + it('uses the filename if the filename is a URL', function() local force_expansion = 1 local filename = 'http://www.neovim.org' |