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

Commita399675

Browse files
committed
In pg_upgrade, improve popen() failure detection by checking for fgets()
failures.
1 parent981e5ac commita399675

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

‎contrib/pg_upgrade/check.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -754,11 +754,11 @@ check_for_support_lib(ClusterInfo *cluster)
754754

755755
snprintf(cmd,sizeof(cmd),"\"%s/pg_config\" --pkglibdir",cluster->bindir);
756756

757-
if ((output=popen(cmd,"r"))==NULL)
758-
pg_log(PG_FATAL,"Could not get pkglibdir data: %s\n",
759-
getErrorText(errno));
757+
if ((output=popen(cmd,"r"))==NULL||
758+
fgets(libdir,sizeof(libdir),output)==NULL)
759+
pg_log(PG_FATAL,"Could not get pkglibdir data using %s: %s\n",
760+
cmd,getErrorText(errno));
760761

761-
fgets(libdir,sizeof(libdir),output);
762762

763763
pclose(output);
764764

@@ -787,11 +787,10 @@ get_bin_version(ClusterInfo *cluster)
787787

788788
snprintf(cmd,sizeof(cmd),"\"%s/pg_ctl\" --version",cluster->bindir);
789789

790-
if ((output=popen(cmd,"r"))==NULL)
791-
pg_log(PG_FATAL,"Could not get pg_ctl version data: %s\n",
792-
getErrorText(errno));
793-
794-
fgets(cmd_output,sizeof(cmd_output),output);
790+
if ((output=popen(cmd,"r"))==NULL||
791+
fgets(cmd_output,sizeof(cmd_output),output)==NULL)
792+
pg_log(PG_FATAL,"Could not get pg_ctl version data using %s: %s\n",
793+
cmd,getErrorText(errno));
795794

796795
pclose(output);
797796

‎contrib/pg_upgrade/controldata.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ get_control_data(ClusterInfo *cluster, bool live_check)
109109
fflush(stderr);
110110

111111
if ((output=popen(cmd,"r"))==NULL)
112-
pg_log(PG_FATAL,"Could not get control data: %s\n",
113-
getErrorText(errno));
112+
pg_log(PG_FATAL,"Could not get control data using %s: %s\n",
113+
cmd,getErrorText(errno));
114114

115115
/* Only pre-8.4 has these so if they are not set below we will check later */
116116
cluster->controldata.lc_collate=NULL;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp