提交 ca18b710 编写于 作者: D Dan Kenigsberg 提交者: Daniel Veillard

Allow surrounding whitespace in uuid

* src/util/uuid.c: extend virUUIDParse to allow leading and trailing
  spaces in UUIDs
上级 2c8eb689
...@@ -146,9 +146,13 @@ virUUIDParse(const char *uuidstr, unsigned char *uuid) { ...@@ -146,9 +146,13 @@ virUUIDParse(const char *uuidstr, unsigned char *uuid) {
/* /*
* do a liberal scan allowing '-' and ' ' anywhere between character * 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; cur = uuidstr;
while (c_isspace(*cur))
cur++;
for (i = 0;i < VIR_UUID_BUFLEN;) { for (i = 0;i < VIR_UUID_BUFLEN;) {
uuid[i] = 0; uuid[i] = 0;
if (*cur == 0) if (*cur == 0)
...@@ -171,6 +175,12 @@ virUUIDParse(const char *uuidstr, unsigned char *uuid) { ...@@ -171,6 +175,12 @@ virUUIDParse(const char *uuidstr, unsigned char *uuid) {
cur++; cur++;
} }
while (*cur) {
if (!c_isspace(*cur))
goto error;
cur++;
}
return 0; return 0;
error: error:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册