mirror of https://github.com/citusdata/citus.git
Merge pull request #1551 from citusdata/fix_pg_worker_list_bug
Fix pg_worker_list use-after-free bugpull/1566/head
commit
f1b51d7bbe
|
@ -1367,14 +1367,14 @@ ParseWorkerNodeFileAndRename()
|
||||||
workerNodeList = lappend(workerNodeList, workerNode);
|
workerNodeList = lappend(workerNodeList, workerNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
FreeFile(workerFileStream);
|
|
||||||
free(workerFilePath);
|
|
||||||
|
|
||||||
/* rename the file, marking that it is not used anymore */
|
/* rename the file, marking that it is not used anymore */
|
||||||
appendStringInfo(renamedWorkerFilePath, "%s", workerFilePath);
|
appendStringInfo(renamedWorkerFilePath, "%s", workerFilePath);
|
||||||
appendStringInfo(renamedWorkerFilePath, ".obsolete");
|
appendStringInfo(renamedWorkerFilePath, ".obsolete");
|
||||||
rename(workerFilePath, renamedWorkerFilePath->data);
|
rename(workerFilePath, renamedWorkerFilePath->data);
|
||||||
|
|
||||||
|
FreeFile(workerFileStream);
|
||||||
|
free(workerFilePath);
|
||||||
|
|
||||||
return workerNodeList;
|
return workerNodeList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1424,8 +1424,18 @@ TupleToWorkerNode(TupleDesc tupleDescriptor, HeapTuple heapTuple)
|
||||||
{
|
{
|
||||||
Name nodeClusterName = DatumGetName(nodeCluster);
|
Name nodeClusterName = DatumGetName(nodeCluster);
|
||||||
char *nodeClusterString = NameStr(*nodeClusterName);
|
char *nodeClusterString = NameStr(*nodeClusterName);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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);
|
strlcpy(workerNode->nodeCluster, nodeClusterString, NAMEDATALEN);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return workerNode;
|
return workerNode;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue