Skip to content

Commit 790eaa6

Browse files
committed
Check dup2() results in syslogger
Consistently check the dup2() call results throughout syslogger.c. It's pretty unlikely that they'll error out, but if they do, ereport(FATAL) instead of blissfully continuing on. Spotted by the Coverity scanner.
1 parent f2795f8 commit 790eaa6

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/backend/postmaster/syslogger.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,14 @@ SysLoggerMain(int argc, char *argv[])
210210
close(fileno(stderr));
211211
if (fd != -1)
212212
{
213-
dup2(fd, fileno(stdout));
214-
dup2(fd, fileno(stderr));
213+
if (dup2(fd, fileno(stdout)) < 0)
214+
ereport(FATAL,
215+
(errcode_for_file_access(),
216+
errmsg("could not redirect stdout: %m")));
217+
if (dup2(fd, fileno(stderr)) < 0)
218+
ereport(FATAL,
219+
(errcode_for_file_access(),
220+
errmsg("could not redirect stderr: %m")));
215221
close(fd);
216222
}
217223
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy