2017-04-05 11:54:08 +02:00
|
|
|
Index: gnupg-2.1.20/g10/plaintext.c
|
2013-05-16 12:06:39 +02:00
|
|
|
===================================================================
|
2017-04-05 11:54:08 +02:00
|
|
|
--- gnupg-2.1.20.orig/g10/plaintext.c 2017-04-03 17:13:56.000000000 +0200
|
|
|
|
+++ gnupg-2.1.20/g10/plaintext.c 2017-04-04 09:53:31.541145727 +0200
|
2016-05-10 13:27:26 +02:00
|
|
|
@@ -24,6 +24,7 @@
|
|
|
|
#include <string.h>
|
2013-05-16 12:06:39 +02:00
|
|
|
#include <errno.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
+#include <sys/stat.h>
|
|
|
|
#ifdef HAVE_DOSISH_SYSTEM
|
2014-11-11 11:52:31 +01:00
|
|
|
# include <fcntl.h> /* for setmode() */
|
2013-05-16 12:06:39 +02:00
|
|
|
#endif
|
2016-05-10 13:27:26 +02:00
|
|
|
@@ -38,6 +39,9 @@
|
2017-04-05 11:54:08 +02:00
|
|
|
#include "../common/status.h"
|
|
|
|
#include "../common/i18n.h"
|
2013-05-16 12:06:39 +02:00
|
|
|
|
|
|
|
+/* define safe permissions for creating plaintext files */
|
|
|
|
+#define GPG_SAFE_PERMS (S_IRUSR | S_IWUSR)
|
|
|
|
+#define GPG_SAFE_UMASK (0777 & ~GPG_SAFE_PERMS)
|
|
|
|
|
2015-12-04 16:26:14 +01:00
|
|
|
/* Get the output filename. On success, the actual filename that is
|
|
|
|
used is set in *FNAMEP and a filepointer is returned in *FP.
|
2017-04-05 11:54:08 +02:00
|
|
|
@@ -161,11 +165,15 @@ get_output_file (const byte *embedded_na
|
2014-11-11 11:52:31 +01:00
|
|
|
log_error (_("error creating '%s': %s\n"), fname, gpg_strerror (err));
|
|
|
|
goto leave;
|
|
|
|
}
|
|
|
|
- else if (!(fp = es_fopen (fname, "wb")))
|
|
|
|
- {
|
|
|
|
- err = gpg_error_from_syserror ();
|
|
|
|
- log_error (_("error creating '%s': %s\n"), fname, gpg_strerror (err));
|
|
|
|
- goto leave;
|
2013-05-16 12:06:39 +02:00
|
|
|
+ else {
|
|
|
|
+ mode_t saved_umask = umask(GPG_SAFE_UMASK);
|
2014-11-11 11:52:31 +01:00
|
|
|
+ if( !(fp = es_fopen(fname,"wb")) ) {
|
|
|
|
+ err = gpg_error_from_syserror ();
|
2013-05-16 12:06:39 +02:00
|
|
|
+ log_error(_("error creating `%s': %s\n"), fname, strerror(errno) );
|
|
|
|
+ umask(saved_umask);
|
|
|
|
+ goto leave;
|
|
|
|
+ }
|
|
|
|
+ umask(saved_umask);
|
|
|
|
}
|
|
|
|
#else /* __riscos__ */
|
2014-11-11 11:52:31 +01:00
|
|
|
/* If no output filename was given, i.e. we constructed it, convert
|