Re: [PATCH 2/3] conf: tighten up XML integer parsing

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

 



On 04/18/2012 07:03 PM, Stefan Berger wrote:
> On 04/18/2012 08:14 PM, Eric Blake wrote:
>> https://bugzilla.redhat.com/show_bug.cgi?id=617711 reported that
>> even with my recent patched to allow<memory unit='G'>1</memory>,
>> people can still get away with trying<memory>1G</memory>  and
>> silently get<memory unit='KiB'>1</memory>  instead.  While
>> virt-xml-validate catches the error, our C parser was not.
>>
>> I always love it when I can reduce lines of code while fixing bugs.
>>
>> * src/conf/domain_conf.c (virDomainDefParseXML): Avoid strtoll.
>> * src/conf/storage_conf.c (virStorageDefParsePerms): Likewise.
>> * src/util/xml.c (virXPathLongBase, virXPathULongBase)
>> (virXPathULongLong, virXPathLongLong): Likewise.
>> ---
>>   src/conf/domain_conf.c  |   12 +++++-------
>>   src/conf/storage_conf.c |    6 +++---
>>   src/util/xml.c          |   36 ++++--------------------------------
>>   3 files changed, 12 insertions(+), 42 deletions(-)

Phooey.  I fixed <memory>780M<memory>, but not
<currentMemory>780M</currentMemory>.  It's not enough to change
virXPathULongLong to return -2 instead of 0 on parse errors, but the
caller has to actually check for that return value.  v2 coming up.


>> -        if (*end || (perms->mode&  ~0777)) {
>> +        int tmp;
> 
> Nit: empty line after var decl?
> 
>> + if (virStrToLong_i(mode, NULL, 8, &tmp) < 0 || (tmp & ~0777)) {

Sure, I'll fix that as well in v2.

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]