Merge pull request #1551 from citusdata/fix_pg_worker_list_bug

Fix pg_worker_list use-after-free bug
pull/1566/head
Eren Başak 2017-08-14 19:28:50 +03:00 committed by GitHub
commit f1b51d7bbe
1 changed files with 14 additions and 4 deletions

View File

@ -1367,14 +1367,14 @@ ParseWorkerNodeFileAndRename()
workerNodeList = lappend(workerNodeList, workerNode);
}
FreeFile(workerFileStream);
free(workerFilePath);
/* rename the file, marking that it is not used anymore */
appendStringInfo(renamedWorkerFilePath, "%s", workerFilePath);
appendStringInfo(renamedWorkerFilePath, ".obsolete");
rename(workerFilePath, renamedWorkerFilePath->data);
FreeFile(workerFileStream);
free(workerFilePath);
return workerNodeList;
}
@ -1424,7 +1424,17 @@ TupleToWorkerNode(TupleDesc tupleDescriptor, HeapTuple heapTuple)
{
Name nodeClusterName = DatumGetName(nodeCluster);
char *nodeClusterString = NameStr(*nodeClusterName);
strlcpy(workerNode->nodeCluster, nodeClusterString, NAMEDATALEN);
/*
* nodeClusterString can be null if nodecluster column is not present.
* In the case of extension creation/upgrade, master_initialize_node_metadata
* function is called before the nodecluster column is added to pg_dist_node
* table.
*/
if (nodeClusterString != NULL)
{
strlcpy(workerNode->nodeCluster, nodeClusterString, NAMEDATALEN);
}
}
return workerNode;