[pve-devel] [RFC v2 pve-cluster 1/4] prefer 'name' subkey over 'ring0_addr' for nodename

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Oct 7 18:03:32 CEST 2015



Am 07.10.2015 um 14:26 schrieb Wolfgang Bumiller:
> 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.
Yes, Perl to C switching got me, this is a leak and shamefully one as 
well...
Will repost, thanks for noticing!
>
>>   			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