buildroot/package/cgic/0002-file_enhancements.patch
David Bender 5bda8c9681 cgic: new package
Signed-off-by: Dave Bender <bender@benegon.com>
Signed-off-by: David Bender <codehero@gmail.com>
[yann.morin.1998@free.fr: simplify rules to use -C $(@D); do not install
 in target/ ; add description to patches; split patches into independent
 changes; add hash]
[Thomas: fix minor typos in patch description.]
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2015-01-25 19:21:51 +01:00

57 lines
1.4 KiB
Diff

Create better temporary files.
Probably-Signed-off-by: Dave Bender <bender@benegon.com>
[yann.morin.1998@free.fr: patch was made by Dave, but he
forgot his SoB line, so I added it; split the patch in two
independent fixes]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
diff -rupN cgic206/cgic.c cgic206_tempfile/cgic.c
--- cgic206/cgic.c 2014-03-16 18:17:11.000000000 -0400
+++ cgic206_tempfile/cgic.c 2015-01-21 11:58:45.436384908 -0500
@@ -22,6 +22,8 @@
#define CGICDEBUGEND
#endif /* CGICDEBUG */
+#define _GNU_SOURCE
+
#include <stdio.h>
#include <string.h>
#include <ctype.h>
@@ -34,11 +36,11 @@
#include <io.h>
/* cgic 2.01 */
-#include <fcntl.h>
#else
#include <unistd.h>
#endif /* WIN32 */
+#include <fcntl.h>
#include "cgic.h"
#define cgiStrEq(a, b) (!strcmp((a), (b)))
@@ -636,16 +638,17 @@ static cgiParseResultType getTempFileNam
window between the file's creation and the
chmod call (glibc 2.0.6 and lower might
otherwise have allowed this). */
+ mode_t umode;
int outfd;
+ umode = umask(0600);
strcpy(tfileName, cgicTempDir "/cgicXXXXXX");
- outfd = mkstemp(tfileName);
+ outfd = mkostemp(tfileName, O_CLOEXEC | O_NOATIME);
+ umask(umode);
if (outfd == -1) {
return cgiParseIO;
}
- close(outfd);
- /* Fix the permissions */
- if (chmod(tfileName, 0600) != 0) {
- unlink(tfileName);
+
+ if (close(outfd)) {
return cgiParseIO;
}
#else