From d0573d3db60fd0d522da31a04e451f84a17618d3 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Wed, 21 May 2003 08:48:26 +0000 Subject: [PATCH] * progress.c (handle_progress) * sign.c (write_plaintext_packet) * encode.c (encode_simple,encode_crypt): Make sure that a filename of "-" is considered to be stdin so that iobuf_get_filelength won't get called. This fixes bug 156 reported by Gregery Barton. --- g10/ChangeLog | 8 ++++++++ g10/encode.c | 9 ++++++--- g10/progress.c | 2 +- g10/sign.c | 5 +++-- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/g10/ChangeLog b/g10/ChangeLog index a04cb88d1..57dd35c4b 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,11 @@ +2003-05-21 Werner Koch + + * progress.c (handle_progress) + * sign.c (write_plaintext_packet) + * encode.c (encode_simple,encode_crypt): Make sure that a filename + of "-" is considered to be stdin so that iobuf_get_filelength + won't get called. This fixes bug 156 reported by Gregery Barton. + 2003-05-02 David Shaw * packet.h, build-packet.c (build_sig_subpkt), export.c diff --git a/g10/encode.c b/g10/encode.c index 8a0766674..6468ccfff 100644 --- a/g10/encode.c +++ b/g10/encode.c @@ -1,5 +1,6 @@ /* encode.c - encode data - * Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2000, 2001, 2002, + * 2003 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -291,7 +292,8 @@ encode_simple( const char *filename, int mode, int compat ) either partial length or fixed length with the new style messages. */ - if( filename && !opt.textmode ) { + if (filename && *filename && !(*filename == '-' && !filename[1]) + && !opt.textmode ) { off_t tmpsize; if ( !(tmpsize = iobuf_get_filelength(inp)) ) @@ -522,7 +524,8 @@ encode_crypt( const char *filename, STRLIST remusr ) } } - if( filename && !opt.textmode ) { + if (filename && *filename && !(*filename == '-' && !filename[1]) + && !opt.textmode ) { off_t tmpsize; if ( !(tmpsize = iobuf_get_filelength(inp)) ) diff --git a/g10/progress.c b/g10/progress.c index 0c6f49486..36b293ab5 100644 --- a/g10/progress.c +++ b/g10/progress.c @@ -93,7 +93,7 @@ handle_progress (progress_filter_context_t *pfx, IOBUF inp, const char *name) if (!is_status_enabled ()) return; - if (name) + if (name && *name && !(*name == '-' && !name[1])) filesize = iobuf_get_filelength (inp); else if (opt.set_filesize) filesize = opt.set_filesize; diff --git a/g10/sign.c b/g10/sign.c index 852632098..6e6566048 100644 --- a/g10/sign.c +++ b/g10/sign.c @@ -1,5 +1,6 @@ /* sign.c - sign data - * Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2000, 2001, 2002, + * 2003 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -483,7 +484,7 @@ write_plaintext_packet (IOBUF out, IOBUF inp, const char *fname, int ptmode) } /* try to calculate the length of the data */ - if (fname) { + if (fname && *fname && !(*fname=='-' && !fname[1])) { if( !(filesize = iobuf_get_filelength(inp)) ) log_info (_("WARNING: `%s' is an empty file\n"), fname);