diff --git a/common/name-value.c b/common/name-value.c index 0b32a4442..ebc48e513 100644 --- a/common/name-value.c +++ b/common/name-value.c @@ -665,7 +665,7 @@ do_nvc_parse (nvc_t *result, int *errlinep, estream_t stream, if (errlinep) *errlinep = 0; - while ((len = es_read_line (stream, &buf, &buf_len, NULL))) + while ((len = es_read_line (stream, &buf, &buf_len, NULL)) > 0) { char *p; if (errlinep) @@ -735,6 +735,11 @@ do_nvc_parse (nvc_t *result, int *errlinep, estream_t stream, goto leave; } } + if (len < 0) + { + err = gpg_error_from_syserror (); + goto leave; + } /* Add the final entry. */ if (raw_value)