mirror of
https://github.com/vim/vim.git
synced 2025-07-25 10:54:51 -04:00
patch 8.0.0337: invalid memory access in :recover command
Problem: Invalid memory access in :recover command. Solution: Avoid access before directory name. (Dominique Pelle, closes #1488)
This commit is contained in:
parent
3df0173fa6
commit
c525e3a1c2
@ -2177,6 +2177,7 @@ test_arglist \
|
|||||||
test_pyx2 \
|
test_pyx2 \
|
||||||
test_pyx3 \
|
test_pyx3 \
|
||||||
test_quickfix \
|
test_quickfix \
|
||||||
|
test_recover \
|
||||||
test_regexp_latin \
|
test_regexp_latin \
|
||||||
test_regexp_utf8 \
|
test_regexp_utf8 \
|
||||||
test_reltime \
|
test_reltime \
|
||||||
|
@ -1863,8 +1863,10 @@ recover_names(
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if defined(UNIX) || defined(WIN3264)
|
#if defined(UNIX) || defined(WIN3264)
|
||||||
p = dir_name + STRLEN(dir_name);
|
int len = STRLEN(dir_name);
|
||||||
if (after_pathsep(dir_name, p) && p[-1] == p[-2])
|
|
||||||
|
p = dir_name + len;
|
||||||
|
if (after_pathsep(dir_name, p) && len > 1 && p[-1] == p[-2])
|
||||||
{
|
{
|
||||||
/* Ends with '//', Use Full path for swap name */
|
/* Ends with '//', Use Full path for swap name */
|
||||||
tail = make_percent_swname(dir_name, fname_res);
|
tail = make_percent_swname(dir_name, fname_res);
|
||||||
@ -3922,8 +3924,10 @@ makeswapname(
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(UNIX) || defined(WIN3264) /* Need _very_ long file names */
|
#if defined(UNIX) || defined(WIN3264) /* Need _very_ long file names */
|
||||||
s = dir_name + STRLEN(dir_name);
|
int len = STRLEN(dir_name);
|
||||||
if (after_pathsep(dir_name, s) && s[-1] == s[-2])
|
|
||||||
|
s = dir_name + len;
|
||||||
|
if (after_pathsep(dir_name, s) && len > 1 && s[-1] == s[-2])
|
||||||
{ /* Ends with '//', Use Full path */
|
{ /* Ends with '//', Use Full path */
|
||||||
r = NULL;
|
r = NULL;
|
||||||
if ((s = make_percent_swname(dir_name, fname)) != NULL)
|
if ((s = make_percent_swname(dir_name, fname)) != NULL)
|
||||||
|
@ -34,6 +34,7 @@ source test_messages.vim
|
|||||||
source test_partial.vim
|
source test_partial.vim
|
||||||
source test_popup.vim
|
source test_popup.vim
|
||||||
source test_put.vim
|
source test_put.vim
|
||||||
|
source test_recover.vim
|
||||||
source test_reltime.vim
|
source test_reltime.vim
|
||||||
source test_searchpos.vim
|
source test_searchpos.vim
|
||||||
source test_set.vim
|
source test_set.vim
|
||||||
|
14
src/testdir/test_recover.vim
Normal file
14
src/testdir/test_recover.vim
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
" Test :recover
|
||||||
|
|
||||||
|
func Test_recover_root_dir()
|
||||||
|
" This used to access invalid memory.
|
||||||
|
split Xtest
|
||||||
|
set dir=/
|
||||||
|
call assert_fails('recover', 'E305:')
|
||||||
|
close!
|
||||||
|
|
||||||
|
call assert_fails('split Xtest', 'E303:')
|
||||||
|
set dir&
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" TODO: move recover tests from test78.in to here.
|
@ -764,6 +764,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
337,
|
||||||
/**/
|
/**/
|
||||||
336,
|
336,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user