]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Allow surrounding whitespace in uuid
authorDan Kenigsberg <danken@redhat.com>
Thu, 21 Jan 2010 14:28:56 +0000 (15:28 +0100)
committerDaniel Veillard <veillard@redhat.com>
Thu, 21 Jan 2010 14:32:37 +0000 (15:32 +0100)
* src/util/uuid.c: extend virUUIDParse to allow leading and trailing
  spaces in UUIDs

src/util/uuid.c

index 20ed1189fb7d1f7474ae888380164931c5550963..56e53a34feb4dfeb9bb4b765a83edb5cb9421cd1 100644 (file)
@@ -146,9 +146,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)
@@ -171,6 +175,12 @@ virUUIDParse(const char *uuidstr, unsigned char *uuid) {
         cur++;
     }
 
+    while (*cur) {
+        if (!c_isspace(*cur))
+            goto error;
+        cur++;
+    }
+
     return 0;
 
  error: