From: Matthias Bolte Date: Tue, 30 Mar 2010 14:34:43 +0000 (+0200) Subject: openvz: Use strtok_r instead of sscanf for VPS UUID parsing X-Git-Tag: v0.8.0~126 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1778da718517ab6cefcfd138638bcea88e98ddb4;p=thirdparty%2Flibvirt.git openvz: Use strtok_r instead of sscanf for VPS UUID parsing Also free 2k stack space. --- diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index 7fc3cd10e4..d447eb90e2 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -835,8 +835,9 @@ openvzGetVPSUUID(int vpsid, char *uuidstr, size_t len) { char conf_file[PATH_MAX]; char line[1024]; - char uuidbuf[1024]; - char iden[1024]; + char *saveptr; + char *uuidbuf; + char *iden; int fd, ret; int retval = 0; @@ -859,8 +860,10 @@ openvzGetVPSUUID(int vpsid, char *uuidstr, size_t len) break; } - sscanf(line, "%s %s\n", iden, uuidbuf); - if(STREQ(iden, "#UUID:")) { + iden = strtok_r(line, " ", &saveptr); + uuidbuf = strtok_r(NULL, "\n", &saveptr); + + if (iden != NULL && uuidbuf != NULL && STREQ(iden, "#UUID:")) { if (virStrcpy(uuidstr, uuidbuf, len) == NULL) retval = -1; break;