diff options
author | Werner Koch <[email protected]> | 1999-06-26 10:23:06 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 1999-06-26 10:23:06 +0000 |
commit | 080c9ca49f4d0b0aa07e00e1eb84bc39bf4c8562 (patch) | |
tree | 7d387cb3da17d9b3e25aef7f85acbad21f75be7f /util/iobuf.c | |
parent | See ChangeLog: Wed Jun 16 20:16:21 CEST 1999 Werner Koch (diff) | |
download | gnupg-080c9ca49f4d0b0aa07e00e1eb84bc39bf4c8562.tar.gz gnupg-080c9ca49f4d0b0aa07e00e1eb84bc39bf4c8562.zip |
See ChangeLog: Sat Jun 26 12:15:59 CEST 1999 Werner Koch
Diffstat (limited to 'util/iobuf.c')
-rw-r--r-- | util/iobuf.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/util/iobuf.c b/util/iobuf.c index e5379d9ce..31dabace0 100644 --- a/util/iobuf.c +++ b/util/iobuf.c @@ -92,16 +92,22 @@ file_filter(void *opaque, int control, IOBUF chain, byte *buf, size_t *ret_len) if( control == IOBUFCTRL_UNDERFLOW ) { assert( size ); /* need a buffer */ - clearerr( fp ); - nbytes = fread( buf, 1, size, fp ); - if( feof(fp) && !nbytes ) - rc = -1; /* okay: we can return EOF now. */ - else if( ferror(fp) && errno != EPIPE ) { - log_error("%s: read error: %s\n", - a->fname, strerror(errno)); - rc = G10ERR_READ_FILE; + if ( feof(fp)) { /* On terminals you could easiely read as many EOFs as you call */ + rc = -1; /* fread() or fgetc() repeatly. Every call will block until you press */ + *ret_len = 0; /* CTRL-D. So we catch this case before we call fread() again. */ + } + else { + clearerr( fp ); + nbytes = fread( buf, 1, size, fp ); + if( feof(fp) && !nbytes ) + rc = -1; /* okay: we can return EOF now. */ + else if( ferror(fp) && errno != EPIPE ) { + log_error("%s: read error: %s\n", + a->fname, strerror(errno)); + rc = G10ERR_READ_FILE; + } + *ret_len = nbytes; } - *ret_len = nbytes; } else if( control == IOBUFCTRL_FLUSH ) { if( size ) { |