diff src/dosinst.h @ 15941:b9098585d945 v8.1.0976

patch 8.1.0976: dosinstall still has buffer overflow problems commit https://github.com/vim/vim/commit/e4963c543ddcfc4845fa0d42893b6a4e1aa27c47 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Feb 22 19:41:08 2019 +0100 patch 8.1.0976: dosinstall still has buffer overflow problems Problem: Dosinstall still has buffer overflow problems. Solution: Adjust buffer sizes. (Yasuhiro Matsumoto, closes https://github.com/vim/vim/issues/4002)
author Bram Moolenaar <Bram@vim.org>
date Fri, 22 Feb 2019 19:45:12 +0100
parents e43b5e6d9190
children 7e733046db1d
line wrap: on
line diff
--- a/src/dosinst.h
+++ b/src/dosinst.h
@@ -59,7 +59,7 @@ char *searchpath(char *name);
 /* ---------------------------------------- */
 
 
-#define BUFSIZE 512		/* long enough to hold a file name path */
+#define BUFSIZE (MAX_PATH*2)		/* long enough to hold a file name path */
 #define NUL 0
 
 #define FAIL 0
@@ -93,15 +93,15 @@ int	interactive;		/* non-zero when runni
     static void *
 alloc(int len)
 {
-    char *s;
+    void *p;
 
-    s = malloc(len);
-    if (s == NULL)
+    p = malloc(len);
+    if (p == NULL)
     {
 	printf("ERROR: out of memory\n");
 	exit(1);
     }
-    return (void *)s;
+    return p;
 }
 
 /*
@@ -512,7 +512,7 @@ char	*sysdrive;		/* system drive or "c:\
 do_inits(char **argv)
 {
     /* Find out the full path of our executable. */
-    if (my_fullpath(installdir, argv[0], BUFSIZE) == NULL)
+    if (my_fullpath(installdir, argv[0], sizeof(installdir)) == NULL)
     {
 	printf("ERROR: Cannot get name of executable\n");
 	myexit(1);