diff src/findfile.c @ 25364:af5c4fabcf40 v8.2.3219

patch 8.2.3219: :find searches non-existing directories Commit: https://github.com/vim/vim/commit/7a4ca32175bef0f9a177052796bd9addd10dc218 Author: Christian Brabandt <cb@256bit.org> Date: Sun Jul 25 15:08:05 2021 +0200 patch 8.2.3219: :find searches non-existing directories Problem: :find searches non-existing directories. Solution: Check the path is not "..". Update help. (Christian Brabandt, closes #8612, closes #8533)
author Bram Moolenaar <Bram@vim.org>
date Sun, 25 Jul 2021 15:15:04 +0200
parents 5f8dd7b3ae41
children e8e2c4d33b9b
line wrap: on
line diff
--- a/src/findfile.c
+++ b/src/findfile.c
@@ -578,7 +578,16 @@ vim_findfile_init(
 
 	    if (p > search_ctx->ffsc_fix_path)
 	    {
+		// do not add '..' to the path and start upwards searching
 		len = (int)(p - search_ctx->ffsc_fix_path) - 1;
+		if ((len >= 2
+			&& STRNCMP(search_ctx->ffsc_fix_path, "..", 2) == 0)
+			&& (len == 2
+				   || search_ctx->ffsc_fix_path[2] == PATHSEP))
+		{
+		    vim_free(buf);
+		    goto error_return;
+		}
 		STRNCAT(ff_expand_buffer, search_ctx->ffsc_fix_path, len);
 		add_pathsep(ff_expand_buffer);
 	    }