[libvirt] [PATCH] openvz: Handle getline failures in openvzReadConfigParam properly

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 distinguished EOF from other getline failures. --- src/openvz/openvz_conf.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index 2cccd81..bf6ee2c 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -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; -- 1.7.0.4

On 05/27/2011 04:37 AM, Matthias Bolte wrote:
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 distinguished EOF from other getline failures. --- src/openvz/openvz_conf.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)
ACK. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

2011/5/31 Eric Blake <eblake@redhat.com>:
On 05/27/2011 04:37 AM, Matthias Bolte wrote:
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 distinguished EOF from other getline failures. --- src/openvz/openvz_conf.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)
ACK.
Thanks, pushed. Matthias
participants (2)
-
Eric Blake
-
Matthias Bolte