Incorrect fd handling in syslogger.c for Win64 under EXEC_BACKEND
Вложения
В списке pgsql-hackers по дате отправления:
| От | Michael Paquier |
|---|---|
| Тема | Incorrect fd handling in syslogger.c for Win64 under EXEC_BACKEND |
| Дата | |
| Msg-id | YVKO9E/TedXTKWvb@paquier.xyz обсуждение |
| Ответы |
Re: Incorrect fd handling in syslogger.c for Win64 under EXEC_BACKEND
|
| Список | pgsql-hackers |
Hi all,
While reviewing a patch that refactors syslogger.c, we use the
following code to pass down a HANDLE to a forked syslogger as of
syslogger_forkexec():
if (syslogFile != NULL)
snprintf(filenobuf, sizeof(filenobuf), "%ld",
(long) _get_osfhandle(_fileno(syslogFile)));
Then, in the kicked syslogger, the parsing is done as follows in
syslogger_parseArgs() for WIN32, with a simple atoi():
fd = atoi(*argv++);
_get_osfhandle() returns intptr_t whose size is system-dependent, as
it would be 32b for Win32 and 64b for Win64:
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/get-osfhandle
https://docs.microsoft.com/en-us/cpp/c-runtime-library/standard-types
As long is 4 bytes on Windows, we would run into overflows here if the
handle is out of the normal 32b range. So the logic as coded is fine
for Win32, but it could be wrong under Win64.
Am I missing something obvious? One thing that we could do here is
to do the parsing with pg_lltoa() while printing the argument with
INT64_FORMAT, no?
Thoughts?
--
Michael
В списке pgsql-hackers по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера