[libvirt] [PATCH]: don't harcode buffer for getgrnam_r

Guido Günther agx at sigxcpu.org
Thu Apr 16 12:14:13 UTC 2009

On Thu, Apr 16, 2009 at 09:56:27AM +0200, Daniel Veillard wrote:
> On Thu, Apr 16, 2009 at 09:19:38AM +0200, Guido Günther wrote:
> > Hi,
> > determines the maximum needed buffersize for getgrnam_r using sysconf
> > instead of hardcoding it to 1024 and increases the buffer on ERANGE.
> > The latter is needed since sysconf is allowed to return -1. Furthermore
> > some glibc versions seem to return a too small buffer on amd64
> > (http://bugs.debian.org/520744). O.k. to apply?
>   It looks a bit weird, using sysconf but 1/ allowing it to fail so
> doing the 2/ 1024 value and loop on ERANGE , but well if I understand
> correctly taht's forced by some glibc broken behaviour.
Yes, sysconf is allowed to return -1 here.

>   My take is that the *= 2 size loop should be bounded to avoid eating
> all memory on some intermediate not size related error. Can we really
glibc shouldn't return ERANGE then, but better safe than sorry. I've
added that check in the attched patch.
 -- Guido
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-increase-buffer-on-ERANGE.patch
Type: text/x-diff
Size: 2602 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20090416/ee587ff2/attachment-0001.bin>

More information about the libvir-list mailing list