aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2001-03-29 09:18:11 +0000
committerWerner Koch <[email protected]>2001-03-29 09:18:11 +0000
commit424f5d6d9350d3cd60f1e476b87c5e3cb1b8bdbf (patch)
tree9344fcbfa7497dbe366052e44d1e43d19ef66ffa
parentFixed nasty Hash bug (diff)
downloadgnupg-424f5d6d9350d3cd60f1e476b87c5e3cb1b8bdbf.tar.gz
gnupg-424f5d6d9350d3cd60f1e476b87c5e3cb1b8bdbf.zip
Allow to enter an alternate filename
-rw-r--r--THANKS1
-rw-r--r--TODO16
-rw-r--r--g10/ChangeLog7
-rw-r--r--g10/openfile.c18
-rw-r--r--g10/plaintext.c14
-rw-r--r--util/ChangeLog7
-rw-r--r--util/iobuf.c5
-rw-r--r--util/miscutil.c16
8 files changed, 55 insertions, 29 deletions
diff --git a/THANKS b/THANKS
index 5e340829b..8e89aec60 100644
--- a/THANKS
+++ b/THANKS
@@ -138,6 +138,7 @@ Sam Roberts [email protected]
Sean MacLennan [email protected]
Serge Munhoven [email protected]
+Stefan Bellon [email protected]
Stefan Karrmann [email protected]
Stefan Keller [email protected]
Steffen Ullrich [email protected]
diff --git a/TODO b/TODO
index c970ce2d5..7420e489d 100644
--- a/TODO
+++ b/TODO
@@ -7,8 +7,6 @@
* check whether we can remove all the expire stuff in trustdb because this
is now done in getkey.
- * ask for alternate filename?
-
* Can we output things like the preferences?
* We need another special packet at the end of a clearsign message to mark
@@ -49,10 +47,6 @@
Scheduled for 1.1
-----------------
- * David C Niemi pointed out that the code for --no-default-keyring does not
- work as expected, because in g10/g10.c sec_nring will be set in the option
- switch but later checked to see whether there are any keyrings.
-
* export by user-IDs does only export the first matching name which leads
to a problem in cases where there are 2 keys with identically user-IDs.
@@ -61,8 +55,6 @@ Scheduled for 1.1
* Speed up calculation of key validation.
- * print a warning when a revoked/expired _secret_ key is used.
-
* --disable-asm should still assemble _udiv_qrnnd when needed
* Skip RO keyrings when importing a key.
@@ -88,9 +80,6 @@ Nice to have
test program. Use it with the test suite?
* add test cases for invalid data (scrambled armor or other random data)
* add checking of armor trailers
- * Burn the buffers used by fopen(), or use read(2). Does this
- really make sense? And while we are at it: implement a secure deletion
- stuff?
* the pubkey encrypt functions should do some sanity checks.
* dynload: implement the hint stuff.
* "gpg filename.tar.gz.asc" should work like --verify (-sab).
@@ -98,8 +87,7 @@ Nice to have
verification status of the message to the output (i.e. write something to
the --output file and not only to stderr.
* configure option where to find zlib
- * Display more validity information about the user IDs at certain places.
- We need a more general function to extract such kind of info from the
- trustdb.
* Evaluate whether it make sense to replace the namehashs either by
using the user ID directly or by using pointers into the trustdb.
+
+
diff --git a/g10/ChangeLog b/g10/ChangeLog
index caad560e5..dedaf7e50 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,10 @@
+2001-03-29 Werner Koch <[email protected]>
+
+ * openfile.c (ask_outfile_name): Trim spaces.
+ (open_outfile): Allow to enter an alternate filename. Thanks to
+ Stefan Bellon.
+ * plaintext.c (handle_plaintext): Ditto.
+
2001-03-28 Werner Koch <[email protected]>
* mainproc.c (do_check_sig): Allow direct key and subkey
diff --git a/g10/openfile.c b/g10/openfile.c
index 74050fee6..79c99785a 100644
--- a/g10/openfile.c
+++ b/g10/openfile.c
@@ -155,6 +155,8 @@ ask_outfile_name( const char *name, size_t namelen )
fname = defname; defname = NULL;
}
m_free(defname);
+ if (fname)
+ trim_spaces (fname);
return fname;
}
@@ -221,7 +223,19 @@ open_outfile( const char *iname, int mode, IOBUF *a )
name = buf;
}
- if( overwrite_filep( name ) ) {
+ rc = 0;
+ while( !overwrite_filep (name) ) {
+ char *tmp = ask_outfile_name (NULL, 0);
+ if ( !tmp || !*tmp ) {
+ m_free (tmp);
+ rc = G10ERR_FILE_EXISTS;
+ break;
+ }
+ m_free (buf);
+ name = buf = tmp;
+ }
+
+ if( !rc ) {
if( !(*a = iobuf_create( name )) ) {
log_error(_("%s: can't create: %s\n"), name, strerror(errno) );
rc = G10ERR_CREATE_FILE;
@@ -229,8 +243,6 @@ open_outfile( const char *iname, int mode, IOBUF *a )
else if( opt.verbose )
log_info(_("writing to `%s'\n"), name );
}
- else
- rc = G10ERR_FILE_EXISTS;
m_free(buf);
}
return rc;
diff --git a/g10/plaintext.c b/g10/plaintext.c
index 5820af6c6..f883f4a73 100644
--- a/g10/plaintext.c
+++ b/g10/plaintext.c
@@ -89,9 +89,17 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
setmode ( fileno(fp) , O_BINARY );
#endif
}
- else if( !overwrite_filep( fname ) ) {
- rc = G10ERR_CREATE_FILE;
- goto leave;
+ else {
+ while( !overwrite_filep (fname) ) {
+ char *tmp = ask_outfile_name (NULL, 0);
+ if ( !tmp || !*tmp ) {
+ m_free (tmp);
+ rc = G10ERR_CREATE_FILE;
+ goto leave;
+ }
+ m_free (fname);
+ fname = tmp;
+ }
}
if( fp || nooutput )
diff --git a/util/ChangeLog b/util/ChangeLog
index b1236dea0..3a6ed109e 100644
--- a/util/ChangeLog
+++ b/util/ChangeLog
@@ -1,3 +1,10 @@
+2001-03-29 Werner Koch <[email protected]>
+
+ * miscutil.c (answer_is_yes): An empty string does now return no.
+ (answer_is_yes_no_quit): Likewise.
+
+ * iobuf.c (iobuf_close): Burn the buffers.
+
2001-03-26 Werner Koch <[email protected]>
* ttyio.c: Define TERMDEVICE depending on OS.
diff --git a/util/iobuf.c b/util/iobuf.c
index 471653877..dd1a2b181 100644
--- a/util/iobuf.c
+++ b/util/iobuf.c
@@ -905,7 +905,10 @@ iobuf_close ( IOBUF a )
a->chain, NULL, &dummy_len)) )
log_error("IOBUFCTRL_FREE failed on close: %s\n", g10_errstr(rc) );
m_free(a->real_fname);
- m_free(a->d.buf);
+ if (a->d.buf) {
+ memset (a->d.buf, 0, a->d.size); /* erase the buffer */
+ m_free(a->d.buf);
+ }
m_free(a);
}
return rc;
diff --git a/util/miscutil.c b/util/miscutil.c
index d1af604e6..be41d93d4 100644
--- a/util/miscutil.c
+++ b/util/miscutil.c
@@ -281,17 +281,17 @@ answer_is_yes( const char *s )
if( !stricmp(s, long_yes ) )
return 1;
- if( strchr( short_yes, *s ) && !s[1] )
+ if( *s && strchr( short_yes, *s ) && !s[1] )
return 1;
/* test for no strings to catch ambiguities for the next test */
if( !stricmp(s, long_no ) )
return 0;
- if( strchr( short_no, *s ) && !s[1] )
+ if( *s && strchr( short_no, *s ) && !s[1] )
return 0;
/* test for the english version (for those who are used to type yes) */
if( !stricmp(s, "yes" ) )
return 1;
- if( strchr( "yY", *s ) && !s[1] )
+ if( *s && strchr( "yY", *s ) && !s[1] )
return 1;
return 0;
}
@@ -316,19 +316,19 @@ answer_is_yes_no_quit( const char *s )
return 1;
if( !stricmp(s, long_quit ) )
return -1;
- if( strchr( short_no, *s ) && !s[1] )
+ if( *s && strchr( short_no, *s ) && !s[1] )
return 0;
- if( strchr( short_yes, *s ) && !s[1] )
+ if( *s && strchr( short_yes, *s ) && !s[1] )
return 1;
- if( strchr( short_quit, *s ) && !s[1] )
+ if( *s && strchr( short_quit, *s ) && !s[1] )
return -1;
if( !stricmp(s, "yes" ) )
return 1;
if( !stricmp(s, "quit" ) )
return -1;
- if( strchr( "yY", *s ) && !s[1] )
+ if( *s && strchr( "yY", *s ) && !s[1] )
return 1;
- if( strchr( "qQ", *s ) && !s[1] )
+ if( *s && strchr( "qQ", *s ) && !s[1] )
return -1;
return 0;
}