]> git.ipfire.org Git - thirdparty/libvirt.git/commit
cgroup: reuse buffer for getline
authorJán Tomko <jtomko@redhat.com>
Wed, 17 Jul 2013 08:56:05 +0000 (10:56 +0200)
committerJán Tomko <jtomko@redhat.com>
Thu, 1 Aug 2013 14:58:42 +0000 (16:58 +0200)
commitfcbeadf3e881971fce134b94c2a61bfd5070ec43
treecb6658d3203743b21be65318ae13bbd6df45c967
parentc84efe887416565276a1c9eeaa0fcf3314565c18
cgroup: reuse buffer for getline

Reuse the buffer for getline and track buffer allocation
separately from the string length to prevent unlikely
out-of-bounds memory access.

This fixes the following leak that happened when zero bytes were read:

==404== 120 bytes in 1 blocks are definitely lost in loss record 1,344 of 1,671
==404==    at 0x4C2C71B: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==404==    by 0x906F862: getdelim (iogetdelim.c:68)
==404==    by 0x52A48FB: virCgroupPartitionNeedsEscaping (vircgroup.c:1136)
==404==    by 0x52A0FB4: virCgroupPartitionEscape (vircgroup.c:1171)
==404==    by 0x52A0EA4: virCgroupNewDomainPartition (vircgroup.c:1450)
(cherry picked from commit cc7329317fee6088055d7b09594c19f1b8fec5e3)
src/util/vircgroup.c