[PATCH] Bunch of options for vfs_fileid

Christian Ambach ambi at samba.org
Sat Jan 6 07:53:01 UTC 2018


Hi Jeremy,

>> Please review&push if happy. Thanks!
>
> LGTM, RB+ and pushed - thanks !

I am not sure if the following two spots are correct.
Maybe you can give them a second look?

> +	char hostname[HOST_NAME_MAX+1];
[...]
> +
> +	rc = gethostname(hostname, HOST_NAME_MAX+1);
> +	if (rc != 0) {
> +		DBG_ERR("gethostname failed\n");
> +		return UINT64_MAX;
> +	}
man gethostname on Linux notes a discrepancy between Linux and POSIX:
in POSIX gethostname is allowed to return up to 255 characters, while
HOST_NAME_MAX is just 64 characters on Linux. Not sure how this looks
like on other platforms. Maybe it makes more sense to use an array of
size 256 to be on the safe side?
The error path that returns the same number for all devices might be
problematic too, as it will then generate the same fileid for files
with the same inode number on different filesystems.

> +	TALLOC_FREE(devname);
> +
> +	id = fileid_uint64_hash((uint8_t *)devname, devname_len);

Isn't this a use-after-free?

Regards,
Christian





More information about the samba-technical mailing list