[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH] logging: fix off-by-one bug



On Mon, Mar 21, 2011 at 10:24:05AM -0600, Eric Blake wrote:
> On 03/21/2011 02:20 AM, Daniel Veillard wrote:
> > On Fri, Mar 18, 2011 at 08:31:22PM -0600, Eric Blake wrote:
> >  Well, I tend to prefer having a 0 at the end of character arrays
> > in C, this can be useful for example when debugging, so slightly
> > preferring one extra byte malloc for safety, either way not a big
> > deal, but let's fix this,
> 
> I see two ways to do things - either malloc an extra byte (which will
> always be NUL from the malloc, so deleting 'virLogBuffer[virLogSize] =
> 0' is still okay), or by touching the rest of the code to always leave
> virLogBuffer[virLogSize-1] as NUL (more invasive, and caps the useful
> log to virLogSize-1).  Do you want me to prepare a followup patch, and
> if so, for which of those two options?

  it's really a minor issue, malloc'ing an extra byte sounds fine to me.

Daniel

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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]