1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

gpg: Use is_secured_filename before opening the file.

* g10/gpg.c (print_mds): Check by is_secured_filename, earlier.
* g10/tdbdump.c (import_ownertrust): Likewise.

--

GnuPG-bug-id: 6508
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2023-07-14 15:49:23 +09:00
parent cf270b0d30
commit 5d375bb168
No known key found for this signature in database
GPG Key ID: 640114AF89DE6054
2 changed files with 8 additions and 11 deletions

View File

@ -5622,13 +5622,13 @@ print_mds( const char *fname, int algo )
}
else
{
fp = es_fopen (fname, "rb" );
if (fp && is_secured_file (es_fileno (fp)))
if (is_secured_filename (fname))
{
es_fclose (fp);
fp = NULL;
gpg_err_set_errno (EPERM);
}
else
fp = es_fopen (fname, "rb" );
}
if (!fp)
{

View File

@ -141,15 +141,12 @@ import_ownertrust (ctrl_t ctrl, const char *fname )
fname = "[stdin]";
is_stdin = 1;
}
else if( !(fp = es_fopen( fname, "r" )) ) {
else if (is_secured_filename (fname)) {
gpg_err_set_errno (EPERM);
log_error (_("can't open '%s': %s\n"), fname, strerror(errno) );
return;
}
if (is_secured_file (es_fileno (fp)))
{
es_fclose (fp);
gpg_err_set_errno (EPERM);
else if( !(fp = es_fopen( fname, "r" )) ) {
log_error ( _("can't open '%s': %s\n"), fname, strerror(errno) );
return;
}