summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/backend/port/win32/signal.c4
-rw-r--r--src/port/kill.c2
-rw-r--r--src/port/path.c12
3 files changed, 11 insertions, 7 deletions
diff --git a/src/backend/port/win32/signal.c b/src/backend/port/win32/signal.c
index 9c48df3114..91bc957919 100644
--- a/src/backend/port/win32/signal.c
+++ b/src/backend/port/win32/signal.c
@@ -178,7 +178,7 @@ pgwin32_create_signal_listener(pid_t pid)
char pipename[128];
HANDLE pipe;
- wsprintf(pipename, "\\\\.\\pipe\\pgsignal_%d", (int) pid);
+ snprintf(pipename, sizeof(pipename), "\\\\.\\pipe\\pgsignal_%u", (int) pid);
pipe = CreateNamedPipe(pipename, PIPE_ACCESS_DUPLEX,
PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
@@ -251,7 +251,7 @@ pg_signal_thread(LPVOID param)
char pipename[128];
HANDLE pipe = pgwin32_initial_signal_pipe;
- wsprintf(pipename, "\\\\.\\pipe\\pgsignal_%d", GetCurrentProcessId());
+ snprintf(pipename, sizeof(pipename), "\\\\.\\pipe\\pgsignal_%u", GetCurrentProcessId());
for (;;)
{
diff --git a/src/port/kill.c b/src/port/kill.c
index 30f3b8e5fb..907f5e8c6f 100644
--- a/src/port/kill.c
+++ b/src/port/kill.c
@@ -38,7 +38,7 @@ pgkill(int pid, int sig)
errno = EINVAL;
return -1;
}
- wsprintf(pipename, "\\\\.\\pipe\\pgsignal_%i", pid);
+ snprintf(pipename, sizeof(pipename), "\\\\.\\pipe\\pgsignal_%u", pid);
if (!CallNamedPipe(pipename, &sigData, 1, &sigRet, 1, &bytes, 1000))
{
if (GetLastError() == ERROR_FILE_NOT_FOUND)
diff --git a/src/port/path.c b/src/port/path.c
index ba4be40008..acc3cdc260 100644
--- a/src/port/path.c
+++ b/src/port/path.c
@@ -628,10 +628,14 @@ get_home_path(char *ret_path)
strlcpy(ret_path, pwd->pw_dir, MAXPGPATH);
return true;
#else
- char tmppath[MAX_PATH];
-
- ZeroMemory(tmppath, sizeof(tmppath));
- if (SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, tmppath) != S_OK)
+ char *tmppath;
+
+ /*
+ * Note: We use getenv here because the more modern SHGetSpecialFolderPath()
+ * will force us to link with shell32.lib which eats valuable desktop heap.
+ */
+ tmppath = getenv("APPDATA");
+ if (!tmppath)
return false;
snprintf(ret_path, MAXPGPATH, "%s/postgresql", tmppath);
return true;