]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
openvz: Fix regression in openvzGetVPSUUID
authorMatthias Bolte <matthias.bolte@googlemail.com>
Fri, 27 May 2011 11:50:13 +0000 (13:50 +0200)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Fri, 27 May 2011 13:49:55 +0000 (15:49 +0200)
Commit f044376530f313a replaced openvz_readline with getline and
changed EOF-handling in the openvzGetVPSUUID.

This patch restores original EOF-handling.

Reported by Jean-Baptiste Rouault.

src/openvz/openvz_conf.c

index 2cccd8131e34717903730d30c2466159dbd18469..5f33f757d0c9d4db27778e22515a31d73a7cde4e 100644 (file)
@@ -863,7 +863,6 @@ openvzGetVPSUUID(int vpsid, char *uuidstr, size_t len)
     char *conf_file;
     char *line = NULL;
     size_t line_size = 0;
-    ssize_t ret;
     char *saveptr = NULL;
     char *uuidbuf;
     char *iden;
@@ -878,13 +877,13 @@ openvzGetVPSUUID(int vpsid, char *uuidstr, size_t len)
         goto cleanup;
 
     while (1) {
-        ret = getline(&line, &line_size, fp);
-        if (ret == -1)
-            goto cleanup;
-
-        if (ret == 0) { /* EoF, UUID was not found */
-            uuidstr[0] = 0;
-            break;
+        if (getline(&line, &line_size, fp) < 0) {
+            if (feof(fp)) { /* EOF, UUID was not found */
+                uuidstr[0] = 0;
+                break;
+            } else {
+                goto cleanup;
+            }
         }
 
         iden = strtok_r(line, " ", &saveptr);