]> granicus.if.org Git - postgresql/commitdiff
Repair multiple breakage in Windows-specific code for appending '.exe'.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 3 Feb 2011 01:26:43 +0000 (20:26 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 3 Feb 2011 01:26:43 +0000 (20:26 -0500)
contrib/pg_upgrade/exec.c

index 3ad9dbb1a28ecccb238a76396419348af566bd9c..7095ba62a8013a4d2f21ef4edfb615b784d53642 100644 (file)
@@ -186,16 +186,10 @@ validate_exec(const char *dir, const char *cmdName)
        snprintf(path, sizeof(path), "%s/%s", dir, cmdName);
 
 #ifdef WIN32
-       /* Win32 requires a .exe suffix for stat() */
-       char            path_exe[MAXPGPATH + sizeof(EXE_EXT) - 1];
-
-       if (strlen(path) >= strlen(EXE_EXT) &&
+       /* Windows requires a .exe suffix for stat() */
+       if (strlen(path) <= strlen(EXE_EXT) ||
                pg_strcasecmp(path + strlen(path) - strlen(EXE_EXT), EXE_EXT) != 0)
-       {
-               strcpy(path_exe, path);
-               strcat(path_exe, EXE_EXT);
-               path = path_exe;
-       }
+               strlcat(path, EXE_EXT, sizeof(path));
 #endif
 
        /*