[libvirt] [PATCH] Eliminate use of large buffer on stack in virFileMakePath.

Daniel Veillard veillard at redhat.com
Tue Jan 26 13:49:11 UTC 2010


On Mon, Jan 25, 2010 at 03:36:30PM +0100, Daniel Veillard wrote:
> On Fri, Jan 22, 2010 at 02:04:19PM -0500, Laine Stump wrote:
> > virFileMakePath is a recursive function that was creates a buffer
> > PATH_MAX bytes long for each recursion (one recursion for each element
> > in the path). This changes it to have no buffers on the stack, and to
> > allocate just one buffer total, no matter how many elements are in the
> > path. Because the modified algorithm requires a char* to be passed in
> > rather than const char *, it is now 2 functions - a toplevel API
> > function that remains identical in function, and a 2nd helper function
> > called for the recursions, which 1) doesn't allocate anything, and 2)
> > takes a char* arg, so it can modify the contents.
> > 
> > src/util/util.c: rewrite virFileMakePath
> 
>   ACK, good catch !

  Okay, pushed, thanks !

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel at veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/




More information about the libvir-list mailing list