]> xenbits.xensource.com Git - libvirt.git/commit
phyp: refactor phypListDomainsGeneric to eliminate buffer overflow
authorEduardo Otubo <otubo@linux.vnet.ibm.com>
Thu, 15 Jul 2010 22:37:48 +0000 (19:37 -0300)
committerLaine Stump <laine@redhat.com>
Fri, 6 Aug 2010 15:22:09 +0000 (11:22 -0400)
commit6324949fb11ce0148f34410f0ebf8f1a69ad82da
tree1cadb86b4c47cf0e8fcddf2aa0a638f900229670
parent30ba39a13e598c74a691a433db59a07cea3b9592
phyp: refactor phypListDomainsGeneric to eliminate buffer overflow

src/phyp/phyp_driver.c:phypListDomainsGeneric was crashing due to a buffer
overflow if any line returned from virRun wasn't <=10 characters.

Since virStrToLong_i recognizes any non-numeric as a terminator (not
just NULL), there actually is no need to copy the number into a
separate string anyway, so this patch eliminates that copy, the fixed
length buffer, and therefore the potential to overflow.

This change also provided the oppurtunity to eliminate the character
counting loop, instead using the return from virStrToLong_i to point
past the end of the number, then simply skip the \n to get to the
next.
src/phyp/phyp_driver.c