]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
openvz: Handle getline failures in openvzReadConfigParam properly
authorMatthias Bolte <matthias.bolte@googlemail.com>
Fri, 27 May 2011 10:35:50 +0000 (12:35 +0200)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Tue, 31 May 2011 17:38:08 +0000 (19:38 +0200)
The regression fix in 3aab7f2d6b068f0 altered the error handling.
getline returns -1 on failure to read a line (including EOF). The
original openvzReadConfigParam function using openvz_readline only
treated EOF as not-found. The current getline version treats all
getline failures as not-found.

This patch fixes this and distinguishes EOF from other getline
failures.

src/openvz/openvz_conf.c

index 6e32242699219d5ec9ae4d50ea009b2ce14b0410..7c76e6ba5ed5eaf653748f02936cef60f5f4c88e 100644 (file)
@@ -659,7 +659,12 @@ openvzReadConfigParam(const char *conf_file, const char *param, char **value)
         return -1;
 
     VIR_FREE(*value);
-    while (getline(&line, &line_size, fp) >= 0) {
+    while (1) {
+        if (getline(&line, &line_size, fp) < 0) {
+            err = !feof(fp);
+            break;
+        }
+
         if (! STREQLEN(line, param, strlen(param)))
             continue;