[libvirt] [PATCHv2 05/10] vbox: Replace atoi with virStrToLong_i

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

 



Parsing is stricter now and doesn't accept trailing characters
after the actual value or non-number strings anymore. atoi just
returns 0 in case it cannot parse a number from the given string.
Now an error is reported for such a string.
---
 src/vbox/vbox_tmpl.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 05b075f..14fdcda 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -598,7 +598,9 @@ static int PRUnicharToInt(PRUnichar *strUtf16) {
     if (!strUtf8)
         return -1;
 
-    ret = atoi(strUtf8);
+    if (virStrToLong_i(strUtf8, NULL, 10, &ret) < 0)
+        ret = -1;
+
     g_pVBoxGlobalData->pFuncs->pfnUtf8Free(strUtf8);
 
     return ret;
-- 
1.6.3.3

--
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]