Skip to content

Commit 62d0477

Browse files
committed
fix incorrect usage of memcpy() in start_bgworker()
1 parent 945f224 commit 62d0477

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/pathman_workers.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,17 +185,16 @@ start_bgworker(const char bgworker_name[BGW_MAXLEN],
185185
pid_t pid;
186186

187187
/* Initialize worker struct */
188-
memcpy(worker.bgw_name, bgworker_name, BGW_MAXLEN);
189-
memcpy(worker.bgw_function_name, bgworker_proc, BGW_MAXLEN);
190-
memcpy(worker.bgw_library_name, "pg_pathman", BGW_MAXLEN);
188+
memset(&worker, 0, sizeof(worker));
189+
190+
snprintf(worker.bgw_name, BGW_MAXLEN, "%s", bgworker_name);
191+
snprintf(worker.bgw_function_name, BGW_MAXLEN, "%s", bgworker_proc);
192+
snprintf(worker.bgw_library_name, BGW_MAXLEN, "pg_pathman");
191193

192194
worker.bgw_flags = BGWORKER_SHMEM_ACCESS |
193195
BGWORKER_BACKEND_DATABASE_CONNECTION;
194196
worker.bgw_start_time = BgWorkerStart_RecoveryFinished;
195197
worker.bgw_restart_time = BGW_NEVER_RESTART;
196-
#if PG_VERSION_NUM < 100000
197-
worker.bgw_main = NULL;
198-
#endif
199198
worker.bgw_main_arg = bgw_arg;
200199
worker.bgw_notify_pid = MyProcPid;
201200

0 commit comments

Comments
 (0)