[PATCH 00/27] fix talloc stackframe leaks in remaining xx_path callers

Volker Lendecke Volker.Lendecke at SerNet.DE
Mon Nov 3 00:01:17 MST 2014


On Mon, Nov 03, 2014 at 10:28:45AM +1300, Andrew Bartlett wrote:
> On Sun, 2014-11-02 at 20:21 +0100, David Disseldorp wrote:
> > cache_path(), lock_path() and state_path() all call xx_path() to return
> > a string allocated on the talloc_tos() context. The majority of the
> > callers do not free the returned string, nor do they check for
> > allocation failures.
> > 
> > The cache_path() callers were fixed with
> > https://lists.samba.org/archive/samba-technical/2014-October/102836.html
> > This patch-set addresses the remaining lock_path() and state_path()
> > callers.
> > 
> > Feedback appreciated.
> 
> My preference is that functions never return memory on talloc_tos(), and
> that it (or better, a talloc_stackframe context) be passed in as the
> memory context.  That makes it clear what the allocation behaviour is.
> 
> Rusty did this for all the lp_ functions a while back, for example.

Recently I've started to move away from allocating strings
via talloc_tos() for speed reasons. See for example 7a3bda54,
server_id_str_buf. I'm not the one to do it, so it is not up
to me to make recommendations, but a

struct path_buf {
	char buf[PATH_MAX];
};

for type-safety with enough space would nicely solve this
issue for the path-related lp_ functions.

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