pgpool2.git / summary / log / commit / refs
commit fa4bb56004e9273c382e041946e343efe97a6433
Author: Tatsuo Ishii <ishii@postgresql.org>
Date: Sat Oct 19 03:23:22 2013 +0000
Fix occasional segfault in query cache + extended protocol.
When the query is not "cache safe", bind_msg->param_offset was not set
in Bind(). However, Execute() unconditionally uses
bind_msg->param_offset to convert bind parameters to string so that
they can be added to the cached query string and it causes segfault
because bind_msg->param_offset is a garbage. Also logic bug to
calculate bind_msg->param_offset is corrected.
Per bug#76.
src/protocol/pool_proto_modules.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/protocol/pool_proto_modules.c b/src/protocol/pool_proto_modules.c
index 14a8273d7..d92174052 100644
--- a/src/protocol/pool_proto_modules.c
+++ b/src/protocol/pool_proto_modules.c
@@ -697,7 +697,7 @@ POOL_STATUS Execute(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend,
/*
* Add bind message's info to query to search.
*/
- if (bind_msg->param_offset && bind_msg->contents)
+ if (query_context->is_cache_safe && bind_msg->param_offset && bind_msg->contents)
{
/* Extract binary contents from bind message */
char *query_in_bind_msg = bind_msg->contents + bind_msg->param_offset;
@@ -1268,7 +1268,7 @@ POOL_STATUS Bind(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend,
*/
if (query_context->is_cache_safe)
{
- bind_msg->param_offset = sizeof(int) + sizeof(char) * (strlen(portal_name) + strlen(pstmt_name));
+ bind_msg->param_offset = sizeof(char) * (strlen(portal_name) + strlen(pstmt_name) + 2);
}
session_context->uncompleted_message = bind_msg;
[parent: 12270f23683e]