Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite933978

Browse files
committed
In passwordFromFile, don't leak the open file after stat failures.
Oversight ine882bca. Per Coverity.
1 parentc1ff2d8 commite933978

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

‎src/interfaces/libpq/fe-connect.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7482,13 +7482,17 @@ passwordFromFile(const char *hostname, const char *port, const char *dbname,
74827482

74837483
#ifndefWIN32
74847484
if (fstat(fileno(fp),&stat_buf)!=0)
7485+
{
7486+
fclose(fp);
74857487
returnNULL;
7488+
}
74867489

74877490
if (!S_ISREG(stat_buf.st_mode))
74887491
{
74897492
fprintf(stderr,
74907493
libpq_gettext("WARNING: password file \"%s\" is not a plain file\n"),
74917494
pgpassfile);
7495+
fclose(fp);
74927496
returnNULL;
74937497
}
74947498

@@ -7498,6 +7502,7 @@ passwordFromFile(const char *hostname, const char *port, const char *dbname,
74987502
fprintf(stderr,
74997503
libpq_gettext("WARNING: password file \"%s\" has group or world access; permissions should be u=rw (0600) or less\n"),
75007504
pgpassfile);
7505+
fclose(fp);
75017506
returnNULL;
75027507
}
75037508
#else

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp