[rrd-developers] RFC: [PATCH] Portability by avoiding PATH_MAX

Svante Signell svante.signell at gmail.com
Thu May 8 08:22:42 CEST 2014


On Thu, 2014-05-08 at 07:18 +0200, Svante Signell wrote:
> On Thu, 2014-05-08 at 02:05 +0100, Steven Hartland wrote:
> > ----- Original Message ----- 
> > From: "Svante Signell" <svante.signell at gmail.com>
> > To: "rrdtool dev list" <rrd-developers at lists.oetiker.ch>
> > Sent: Tuesday, April 29, 2014 1:35 PM
> > Subject: [rrd-developers] RFC: [PATCH] Portability by avoiding PATH_MAX
> > 
> > 
> > > Hello,

> > This looks like it would cause a lot of unnessary malloc free surely
> > the correct fix for this is to fix the OS config to define PATH_MAX.
> > 
> > Quick look at the patches also show its quite broken:-
> > 
> > +  tmp = malloc(len);
> > +  snprintf(tmp, len, "%s/%s", config_base_dir, *filename);
> >    *filename = tmp;
> > +  free(tmp);
> > 
> > So you just malloced some memory, assigned the pointer to it then freed
> > the memory, so your now going to get a use after free and BOOM!
> 
> This is of course wrong, thanks! You see the reason for having tests
> together with valgrind to find out these problems. Did you find more?

I even had test code for this function, see attachment. Unfortunately
the change did not make it into the patch. Sorry for missing to update
the patch.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_get_abs_path.c
Type: text/x-csrc
Size: 2312 bytes
Desc: not available
Url : http://lists.oetiker.ch/pipermail/rrd-developers/attachments/20140508/33cf0d02/attachment-0001.c 


More information about the rrd-developers mailing list