From 3b98763bd4531c71127b1debfe707882152623f4 Mon Sep 17 00:00:00 2001 From: "David M. Syzdek" Date: Thu, 15 Sep 2022 10:31:50 -0800 Subject: bindletools: refactoring bindle_encodings_src_fileno() --- src/widget-encodings.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/widget-encodings.c b/src/widget-encodings.c index acc32b3..70de289 100644 --- a/src/widget-encodings.c +++ b/src/widget-encodings.c @@ -538,9 +538,11 @@ bindle_encodings_src_fileno( state->line_off = 0; buff = state->buff; - while ((len = read(cnf->state->fdin, &buff[state->buff_len], (state->buff_size-state->buff_len))) > 0) + while ((len = read(cnf->state->fdin, &buff[state->buff_len], (state->buff_size-state->buff_len))) >= 0) { state->buff_len += (size_t)len; + if (state->buff_len == 0) + return(0); buff[state->buff_len] = '\0'; if ((cnf->widget_flags & BINDLE_FLG_DECODE) == BINDLE_FLG_DECODE) { @@ -551,7 +553,9 @@ bindle_encodings_src_fileno( { if (bindle_encodings_action_encode(cnf, method) == -1) return(1); - } + }; + if (len == 0) + return(0); }; if (len == -1) { -- cgit v1.2.3