pgpool2.git / summary / log / commit / refs

commit    3a61e1b13db1bc623abac72252e96b800ea99833
Author:   Muhammad Usama <m.usama@gmail.com>
Date:     Mon Jul 28 12:20:41 2014 +0000

    Fix coverity issue:1111394 Dereference after null check
    Fix coverity issue:1111398 Dereference after null check
    Fix coverity issue:1111399 Explicit null dereferenced
    Fix coverity issue:1111400 Dereference after null check
    Fix coverity issue:1111401 Explicit null dereferenced


src/parallel_query/pool_rewrite_outfuncs.c | 2 +- src/parallel_query/pool_rewrite_query.c | 2 +- src/protocol/pool_process_query.c | 30 ++++++++++++++++++++---------- src/query_cache/pool_memqcache.c | 2 +- src/utils/pool_select_walker.c | 2 ++ 5 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/parallel_query/pool_rewrite_outfuncs.c b/src/parallel_query/pool_rewrite_outfuncs.c index 5fed42861..97f1c6b66 100644 --- a/src/parallel_query/pool_rewrite_outfuncs.c +++ b/src/parallel_query/pool_rewrite_outfuncs.c @@ -5122,7 +5122,7 @@ _rewriteColumnRef(Node *BaseSelect, RewriteQuery *message, ConInfoTodblink *dbli List *list; char first = 0; char *table_name = NULL; - char *column_name = NULL; + char *column_name = ""; if(CheckAggOpt(message)) { diff --git a/src/parallel_query/pool_rewrite_query.c b/src/parallel_query/pool_rewrite_query.c index 8ea1c5e2a..4fc5abeb1 100644 --- a/src/parallel_query/pool_rewrite_query.c +++ b/src/parallel_query/pool_rewrite_query.c @@ -168,7 +168,7 @@ static void examInsertStmt(Node *node,POOL_CONNECTION_POOL *backend, RewriteQuer return; } - list_t = (List *)(((SelectStmt *)insert->selectStmt)->valuesLists); + list_t = insert->selectStmt ? (List *)(((SelectStmt *)insert->selectStmt)->valuesLists) : NULL; if (!list_t) { diff --git a/src/protocol/pool_process_query.c b/src/protocol/pool_process_query.c index 7520f50ff..073d5ba18 100644 --- a/src/protocol/pool_process_query.c +++ b/src/protocol/pool_process_query.c @@ -2617,9 +2617,17 @@ POOL_STATUS do_query(POOL_CONNECTION *backend, char *query, POOL_SELECT_RESULT * if (major == PROTO_MAJOR_V3) { p = packet; - memcpy(&shortval, p, sizeof(short)); - num_fields = htons(shortval); - p += sizeof(short); + if(p) + { + memcpy(&shortval, p, sizeof(short)); + num_fields = htons(shortval); + p += sizeof(short); + } + else + ereport(ERROR, + (errmsg("do query failed"), + errdetail("error while reading data"))); + } if (num_fields > 0) @@ -3335,7 +3343,7 @@ static char *get_insert_command_table_name(InsertStmt *node) /* judge if this is a DROP DATABASE command */ int is_drop_database(Node *node) { - return (IsA(node, DropdbStmt)) ? 1 : 0; + return (node && IsA(node, DropdbStmt)) ? 1 : 0; } /* @@ -3580,14 +3588,16 @@ POOL_STATUS read_kind_from_backend(POOL_CONNECTION *frontend, POOL_CONNECTION_PO pool_read(CONNECTION(backend, i), &len, sizeof(len)); len = htonl(len) - 4; p = pool_read2(CONNECTION(backend, i), len); - if (p == NULL) + if (p) { - pool_error("read_kind_from_backend: failed to read parameter status packet from %d th backend", i); + value = p + strlen(p) + 1; + pool_debug("read_kind_from_backend: parameter name: %s value: %s", p, value); + if (IS_MASTER_NODE_ID(i)) + pool_add_param(&CONNECTION(backend, i)->params, p, value); } - value = p + strlen(p) + 1; - pool_debug("read_kind_from_backend: parameter name: %s value: %s", p, value); - if (IS_MASTER_NODE_ID(i)) - pool_add_param(&CONNECTION(backend, i)->params, p, value); + else + pool_error("read_kind_from_backend: failed to read parameter status packet from %d th backend", i); + } while (kind == 'S'); #ifdef DEALLOCATE_ERROR_TEST diff --git a/src/query_cache/pool_memqcache.c b/src/query_cache/pool_memqcache.c index 066911945..aeb1841bd 100644 --- a/src/query_cache/pool_memqcache.c +++ b/src/query_cache/pool_memqcache.c @@ -3124,7 +3124,7 @@ void pool_handle_query_cache(POOL_CONNECTION_POOL *backend, char *query, Node *n else /* Non cache safe queries */ { /* Non cachable SELECT */ - if (IsA(node, SelectStmt)) + if (node && IsA(node, SelectStmt)) { if (state == 'I') { diff --git a/src/utils/pool_select_walker.c b/src/utils/pool_select_walker.c index 4afad936d..26f09e5b0 100644 --- a/src/utils/pool_select_walker.c +++ b/src/utils/pool_select_walker.c @@ -1010,6 +1010,8 @@ int pool_table_name_to_oid(char *table_name) */ int pool_extract_table_oids_from_select_stmt(Node *node, SelectContext *ctx) { + if(!node) + return 0; if (!IsA(node, SelectStmt)) return 0; [parent: 90ea3e90622c]