View Issue Details

IDProjectCategoryView StatusLast Update
0000061Pgpool-IIBugpublic2013-07-02 13:21
ReportermasanoAssigned Tonagata 
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
PlatformLinuxOSCentOSOS Version5.9
Product Version 
Target VersionFixed in Version 
Summary0000061: Child process xxxx was terminated by segmentation fault
Descriptionpgpool-II 3.2.4 causes segfault by the following operation.
Steps To Reproduce* PostgreSQL 9.2.4
  enable md5 authentication.

* pgpool-II 3.2.4
  enable md5 authentication.

connect to PostgreSQL server with psql client using -U option which specifies '' (empty string).

$ psql -h 127.0.0.1 -p 9999 -U ''

pgpool-II log shows:
Jun 25 13:36:14 dhcp-177-111 pgpool[8570]: Child process 8574 was terminated by segmentation fault
TagsNo tags attached.

Activities

nagata

2013-06-26 11:52

developer   ~0000295

I confirmed the problem. This occurs when enable_pool_hba is true and there are no PostgreSQL user specification with no relation to md5. I'm fixing it now.

nagata

2013-07-02 13:18

developer  

patch_child_0701.diff (1,543 bytes)
diff --git a/child.c b/child.c
index e7c15d0..506613a 100644
--- a/child.c
+++ b/child.c
@@ -989,6 +989,28 @@ static StartupPacket *read_startup_packet(POOL_CONNECTION *cp)
 			return NULL;
 	}
 
+	/* Check a user name was given. */
+	if (sp->major != 1234 &&
+	    (sp->user == NULL || sp->user[0] == '\0'))
+	{
+		pool_send_fatal_message(cp, sp->major, "28000",
+		                        "no PostgreSQL user name specified in startup packet",
+								"",
+								"",
+								__FILE__, __LINE__);
+		pool_error("read_startup_packet: no PostgreSQL user name specified in startup packet");
+		pool_free_startup_packet(sp);
+		alarm(0);
+		pool_signal(SIGALRM, SIG_IGN);
+		return NULL;
+	}
+
+	/* The database defaults to ther user name. */
+	if (sp->database == NULL || sp->database[0] == '\0')
+	{
+		sp->database = strdup(sp->user);
+	}
+
 	pool_debug("Protocol Major: %d Minor: %d database: %s user: %s",
 			   sp->major, sp->minor, sp->database, sp->user);
 	alarm(0);
@@ -997,8 +1019,8 @@ static StartupPacket *read_startup_packet(POOL_CONNECTION *cp)
 }
 
 /*
-* send startup packet
-*/
+ * send startup packet
+ */
 int send_startup_packet(POOL_CONNECTION_POOL_SLOT *cp)
 {
 	int len;
@@ -1011,7 +1033,7 @@ int send_startup_packet(POOL_CONNECTION_POOL_SLOT *cp)
 /*
  * Reuse existing connection
  */
-static bool connect_using_existing_connection(POOL_CONNECTION *frontend, 
+static bool connect_using_existing_connection(POOL_CONNECTION *frontend,
 											  POOL_CONNECTION_POOL *backend,
 											  StartupPacket *sp)
 {
patch_child_0701.diff (1,543 bytes)

nagata

2013-07-02 13:20

developer   ~0000302

I fixed the problem and attached a patch. This is already committed.


When a startup packet has no PostgreSQL user specified, pgpool-II
terminated abnormally. You can reproduce it by

 $ psql -p 9999 -U ''

If enable_pool_hba is on, a child process terminates by segmentation
fault. Otherwise if enable_pool_hba is off, the error message is

 ERROR: pool_discard_cp: cannot get connection pool for user (null) database (null)

In both cases, psql terminates with no message on frontend.

To resolve it, if PostgreSQL user is not specified in startup packet,
the message as following is output to both log and frontend. This is
the same behavior as PostgreSQL.

 FATAL: no PostgreSQL user name specified in startup packet

Issue History

Date Modified Username Field Change
2013-06-25 14:11 masano New Issue
2013-06-26 11:39 nagata Assigned To => nagata
2013-06-26 11:39 nagata Status new => assigned
2013-06-26 11:52 nagata Note Added: 0000295
2013-06-26 11:52 nagata Status assigned => confirmed
2013-07-02 13:18 nagata File Added: patch_child_0701.diff
2013-07-02 13:20 nagata Note Added: 0000302
2013-07-02 13:21 nagata Status confirmed => resolved
2013-07-02 13:21 nagata Resolution open => fixed