[PATCH] ctdb - add sock_packet_header structure and sock_client abstraction

Volker Lendecke Volker.Lendecke at SerNet.DE
Fri Sep 1 05:32:52 UTC 2017


On Fri, Sep 01, 2017 at 12:15:59PM +1000, Amitay Isaacs via samba-technical wrote:
> +int sock_packet_header_pull(uint8_t *buf, size_t buflen,
> +			    struct sock_packet_header *out, size_t *npull)
> +{
> +	size_t offset = 0, np;
> +	int ret;
> +
> +	ret = ctdb_uint32_pull(buf+offset, buflen-offset, &out->length, &np);
> +	if (ret != 0) {
> +		return ret;
> +	}
> +	offset += np;
> +
> +	ret = ctdb_uint32_pull(buf+offset, buflen-offset, &out->reqid, &np);
> +	if (ret != 0) {
> +		return ret;
> +	}
> +	offset += np;
> +
> +	*npull = offset;
> +	return 0;
> +}

I'm always a bit worried about pull functions without overflow checks.
I know this is just an internal protocol, but even there I'd
appreciate if we followed good practices and always check for overflow
and buflen checks.

Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de



More information about the samba-technical mailing list