mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
* misc.c (is_secured_filename): New.
* keydb.c (maybe_create_keyring) * tdbio.c (tdbio_set_dbname) * plaintext.c (handle_plaintext) * openfile.c (copy_options_file, open_outfile) * exec.c (exec_write) * keygen.c (do_generate_keypair, gen_card_key_with_backup) * sign.c (sign_file, clearsign_file) * keyring.c (create_tmp_file, do_copy): Check for secured files before creating them. * keygen.c (print_status_key_created): s/unsigned char/byte/ due to a strange typedef for RISC OS. Noted by Stefan.
This commit is contained in:
parent
0d6defc0da
commit
35774ec568
11 changed files with 159 additions and 36 deletions
28
g10/keygen.c
28
g10/keygen.c
|
@ -167,7 +167,7 @@ copy_mpi (MPI a, unsigned char *buffer, size_t len, size_t *ncopied)
|
|||
static void
|
||||
print_status_key_created (int letter, PKT_public_key *pk, const char *handle)
|
||||
{
|
||||
unsigned char array[MAX_FINGERPRINT_LEN], *s;
|
||||
byte array[MAX_FINGERPRINT_LEN], *s;
|
||||
char *buf, *p;
|
||||
size_t i, n;
|
||||
|
||||
|
@ -2683,9 +2683,14 @@ do_generate_keypair( struct para_data_s *para,
|
|||
outctrl->pub.fname = outctrl->pub.newfname;
|
||||
outctrl->pub.newfname = NULL;
|
||||
|
||||
outctrl->pub.stream = iobuf_create( outctrl->pub.fname );
|
||||
if (is_secured_filename (outctrl->pub.fname) ) {
|
||||
outctrl->pub.stream = NULL;
|
||||
errno = EPERM;
|
||||
}
|
||||
else
|
||||
outctrl->pub.stream = iobuf_create( outctrl->pub.fname );
|
||||
if( !outctrl->pub.stream ) {
|
||||
log_error("can't create `%s': %s\n", outctrl->pub.newfname,
|
||||
log_error(_("can't create `%s': %s\n"), outctrl->pub.newfname,
|
||||
strerror(errno) );
|
||||
return;
|
||||
}
|
||||
|
@ -2707,10 +2712,15 @@ do_generate_keypair( struct para_data_s *para,
|
|||
outctrl->sec.newfname = NULL;
|
||||
|
||||
oldmask = umask (077);
|
||||
outctrl->sec.stream = iobuf_create( outctrl->sec.fname );
|
||||
if (is_secured_filename (outctrl->sec.fname) ) {
|
||||
outctrl->sec.stream = NULL;
|
||||
errno = EPERM;
|
||||
}
|
||||
else
|
||||
outctrl->sec.stream = iobuf_create( outctrl->sec.fname );
|
||||
umask (oldmask);
|
||||
if( !outctrl->sec.stream ) {
|
||||
log_error("can't create `%s': %s\n", outctrl->sec.newfname,
|
||||
log_error(_("can't create `%s': %s\n"), outctrl->sec.newfname,
|
||||
strerror(errno) );
|
||||
return;
|
||||
}
|
||||
|
@ -3328,7 +3338,13 @@ gen_card_key_with_backup (int algo, int keyno, int is_primary,
|
|||
|
||||
fname = make_filename (backup_dir, name_buffer, NULL);
|
||||
oldmask = umask (077);
|
||||
fp = iobuf_create (fname);
|
||||
if (is_secured_filename (fname))
|
||||
{
|
||||
fp = NULL;
|
||||
errno = EPERM;
|
||||
}
|
||||
else
|
||||
fp = iobuf_create (fname);
|
||||
umask (oldmask);
|
||||
if (!fp)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue