mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
* openfile.c (ask_outfile_name): Fixed buffer overflow occurring
if make_printable_string returns a longer string. Fixes bug 728.
This commit is contained in:
parent
80007b9411
commit
fecadab9c3
@ -1,3 +1,8 @@
|
||||
2006-11-27 Werner Koch <wk@g10code.com>
|
||||
|
||||
* openfile.c (ask_outfile_name): Fixed buffer overflow occurring
|
||||
if make_printable_string returns a longer string. Fixes bug 728.
|
||||
|
||||
2006-11-21 Werner Koch <wk@g10code.com>
|
||||
|
||||
* Makefile.am (needed_libs): libgnu needs to come after libcommon.
|
||||
|
@ -95,7 +95,7 @@ overwrite_filep( const char *fname )
|
||||
|
||||
|
||||
/****************
|
||||
* Strip know extensions from iname and return a newly allocated
|
||||
* Strip known extensions from iname and return a newly allocated
|
||||
* filename. Return NULL if we can't do that.
|
||||
*/
|
||||
char *
|
||||
@ -126,10 +126,10 @@ make_outfile_name( const char *iname )
|
||||
}
|
||||
|
||||
|
||||
/****************
|
||||
* Ask for a outputfilename and use the given one as default.
|
||||
* Return NULL if no file has been given or it is not possible to
|
||||
* ask the user.
|
||||
/* Ask for an output filename; use the given one as default. Return
|
||||
NULL if no file has been given or if it is not possible to ask the
|
||||
user. NAME is the template len which might conatin enbedded Nuls.
|
||||
NAMELEN is its actual length.
|
||||
*/
|
||||
char *
|
||||
ask_outfile_name( const char *name, size_t namelen )
|
||||
@ -143,23 +143,25 @@ ask_outfile_name( const char *name, size_t namelen )
|
||||
if ( opt.batch )
|
||||
return NULL;
|
||||
|
||||
s = _("Enter new filename");
|
||||
|
||||
n = strlen(s) + namelen + 10;
|
||||
defname = name && namelen? make_printable_string (name, namelen, 0) : NULL;
|
||||
|
||||
s = _("Enter new filename");
|
||||
n = strlen(s) + (defname?strlen (defname):0) + 10;
|
||||
prompt = xmalloc (n);
|
||||
if (defname)
|
||||
sprintf(prompt, "%s [%s]: ", s, defname );
|
||||
snprintf (prompt, n-1, "%s [%s]: ", s, defname );
|
||||
else
|
||||
sprintf(prompt, "%s: ", s );
|
||||
snprintf (prompt, n-1, "%s: ", s );
|
||||
tty_enable_completion(NULL);
|
||||
fname = cpr_get ("openfile.askoutname", prompt );
|
||||
cpr_kill_prompt ();
|
||||
tty_disable_completion ();
|
||||
xfree (prompt);
|
||||
if( !*fname ) {
|
||||
xfree( fname ); fname = NULL;
|
||||
fname = defname; defname = NULL;
|
||||
if ( !*fname )
|
||||
{
|
||||
xfree (fname);
|
||||
fname = defname;
|
||||
defname = NULL;
|
||||
}
|
||||
xfree (defname);
|
||||
if (fname)
|
||||
|
Loading…
x
Reference in New Issue
Block a user