[Libvir] [PATCH] fix negative value handling of virConfParseLong()

Hi, I found a bug about negative value at virConfParseLong() in conf.c. This patch fixes it. Signed-off-by: Tatsuro Enokura <fj7716hz@aa.jp.fujitsu.com> Thanks, Tatsuro Enokura. -------------------------------------------------------------------------- Index: libvirt/src/conf.c =================================================================== RCS file: /data/cvs/libvirt/src/conf.c,v retrieving revision 1.11 diff -u -p -r1.11 conf.c --- libvirt/src/conf.c 4 Jul 2007 09:16:23 -0000 1.11 +++ libvirt/src/conf.c 19 Oct 2007 08:37:36 -0000 @@ -345,6 +345,8 @@ virConfParseLong(virConfParserCtxtPtr ct l = l * 10 + (CUR - '0'); NEXT; } + if (neg) + l *= -1; *val = l; return(0); } --------------------------------------------------------------------------

Tatsuro Enokura wrote:
Hi,
I found a bug about negative value at virConfParseLong() in conf.c. This patch fixes it.
Signed-off-by: Tatsuro Enokura <fj7716hz@aa.jp.fujitsu.com>
Thanks, Tatsuro Enokura.
-------------------------------------------------------------------------- Index: libvirt/src/conf.c =================================================================== RCS file: /data/cvs/libvirt/src/conf.c,v retrieving revision 1.11 diff -u -p -r1.11 conf.c --- libvirt/src/conf.c 4 Jul 2007 09:16:23 -0000 1.11 +++ libvirt/src/conf.c 19 Oct 2007 08:37:36 -0000 @@ -345,6 +345,8 @@ virConfParseLong(virConfParserCtxtPtr ct l = l * 10 + (CUR - '0'); NEXT; } + if (neg) + l *= -1; *val = l; return(0); }
Good catch! +1 Rich. -- Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/ Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 03798903

On Fri, Oct 19, 2007 at 10:02:40AM +0100, Richard W.M. Jones wrote:
Tatsuro Enokura wrote:
Hi,
I found a bug about negative value at virConfParseLong() in conf.c. This patch fixes it.
Signed-off-by: Tatsuro Enokura <fj7716hz@aa.jp.fujitsu.com>
Thanks, Tatsuro Enokura.
-------------------------------------------------------------------------- Index: libvirt/src/conf.c =================================================================== RCS file: /data/cvs/libvirt/src/conf.c,v retrieving revision 1.11 diff -u -p -r1.11 conf.c --- libvirt/src/conf.c 4 Jul 2007 09:16:23 -0000 1.11 +++ libvirt/src/conf.c 19 Oct 2007 08:37:36 -0000 @@ -345,6 +345,8 @@ virConfParseLong(virConfParserCtxtPtr ct l = l * 10 + (CUR - '0'); NEXT; } + if (neg) + l *= -1; *val = l; return(0); }
Good catch!
+1
Right, I just used l = -l; instead, fix commited to CVS, thanks a lot ! Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
participants (3)
-
Daniel Veillard
-
Richard W.M. Jones
-
Tatsuro Enokura