[pve-devel] [RFC v2 pve-cluster 1/4] prefer 'name' subkey over 'ring0_addr' for nodename
Wolfgang Bumiller
w.bumiller at proxmox.com
Wed Oct 7 14:26:25 CEST 2015
On Wed, Oct 07, 2015 at 01:34:57PM +0200, Thomas Lamprecht wrote:
> @@ -97,6 +97,13 @@ cmap_read_clusternodes(
> cfs_critical("cmap_get %s failed %d", key_name, result);
> }
> } else if (strcmp(subkey, "ring0_addr") == 0) {
> + // prefer the 'name' subkey over 'ring0_addr', allows ring0_addr
> + // to be IP addresses without changing the nodename
> + if (name == NULL &&
> + (result = cmap_get_string(handle, key_name, &name)) != CS_OK) {
> + cfs_critical("cmap_get %s failed %d", key_name, result);
> + }
> + } else if (strcmp(subkey, "name") == 0) {
If `ring0_addr` is read before `name` then `cmap_get_string` would
replace `name` without freeing it first - leaking - since `name` is only
freed in the `id != last_id` case and after the loop. (Unless cmap is
sorted, which I doubt, but if it is then this should be commented).
cmap_get_string() only assigns and doesn't care what the pointer
contained before.
> if ((result = cmap_get_string(handle, key_name, &name)) != CS_OK) {
> cfs_critical("cmap_get %s failed %d", key_name, result);
> }
> --
More information about the pve-devel
mailing list