[libvirt] [PATCH] allow (only) surrounding whitespace in uuid

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

 



Please consider something along these lines. Without it, pretty-printed
domxml is rejected due to the whitespace before uuid, and long long
string of hexadecimal digits is accepted.
---
 src/util/uuid.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/src/util/uuid.c b/src/util/uuid.c
index 002a64d..0f2ca96 100644
--- a/src/util/uuid.c
+++ b/src/util/uuid.c
@@ -145,9 +145,13 @@ virUUIDParse(const char *uuidstr, unsigned char *uuid) {
 
     /*
      * do a liberal scan allowing '-' and ' ' anywhere between character
-     * pairs as long as there is 32 of them in the end.
+     * pairs, and surrounding whitespace, as long as there are exactly
+     * 32 hexadecimal digits the end.
      */
     cur = uuidstr;
+    while (c_isspace(*cur))
+        cur++;
+
     for (i = 0;i < VIR_UUID_BUFLEN;) {
         uuid[i] = 0;
         if (*cur == 0)
@@ -170,6 +174,12 @@ virUUIDParse(const char *uuidstr, unsigned char *uuid) {
         cur++;
     }
 
+    while (*cur) {
+        if (!c_isspace(*cur))
+            goto error;
+        cur++;
+    }
+
     return 0;
 
  error:
-- 
1.6.5.2

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