forked from pool/libedit
2b87906d0d
- open all FDs with O_CLOEXEC in the library code. - use gcc visibility by just reusing upstream macros "public" and "protected" OBS-URL: https://build.opensuse.org/request/show/109055 OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/libedit?expand=0&rev=47
80 lines
2.3 KiB
Diff
80 lines
2.3 KiB
Diff
Index: libedit-20110802-3.0/src/readline.c
|
|
===================================================================
|
|
--- libedit-20110802-3.0.orig/src/readline.c
|
|
+++ libedit-20110802-3.0/src/readline.c
|
|
@@ -1175,15 +1175,15 @@ history_truncate_file (const char *filen
|
|
|
|
if (filename == NULL && (filename = _default_history_file()) == NULL)
|
|
return errno;
|
|
- if ((fp = fopen(filename, "r+")) == NULL)
|
|
+ if ((fp = fopen(filename, "r+e")) == NULL)
|
|
return errno;
|
|
strcpy(template, _history_tmp_template);
|
|
- if ((fd = mkstemp(template)) == -1) {
|
|
+ if ((fd = mkostemp(template, O_CLOEXEC)) == -1) {
|
|
ret = errno;
|
|
goto out1;
|
|
}
|
|
|
|
- if ((tp = fdopen(fd, "r+")) == NULL) {
|
|
+ if ((tp = fdopen(fd, "r+e")) == NULL) {
|
|
close(fd);
|
|
ret = errno;
|
|
goto out2;
|
|
Index: libedit-20110802-3.0/src/vi.c
|
|
===================================================================
|
|
--- libedit-20110802-3.0.orig/src/vi.c
|
|
+++ libedit-20110802-3.0/src/vi.c
|
|
@@ -37,6 +37,7 @@
|
|
#include <unistd.h>
|
|
#include <limits.h>
|
|
#include <sys/wait.h>
|
|
+#include <fcntl.h>
|
|
|
|
#if !defined(lint) && !defined(SCCSID)
|
|
#if 0
|
|
@@ -1015,7 +1016,7 @@ vi_histedit(EditLine *el, Int c __attrib
|
|
return CC_ERROR;
|
|
}
|
|
|
|
- fd = mkstemp(tempfile);
|
|
+ fd = mkostemp(tempfile, O_CLOEXEC);
|
|
if (fd < 0)
|
|
return CC_ERROR;
|
|
len = (size_t)(el->el_line.lastchar - el->el_line.buffer);
|
|
Index: libedit-20110802-3.0/src/el.c
|
|
===================================================================
|
|
--- libedit-20110802-3.0.orig/src/el.c
|
|
+++ libedit-20110802-3.0/src/el.c
|
|
@@ -539,7 +539,7 @@ el_source(EditLine *el, const char *fnam
|
|
#endif
|
|
}
|
|
if (fp == NULL)
|
|
- fp = fopen(fname, "r");
|
|
+ fp = fopen(fname, "re");
|
|
if (fp == NULL) {
|
|
el_free(path);
|
|
return -1;
|
|
Index: libedit-20110802-3.0/src/history.c
|
|
===================================================================
|
|
--- libedit-20110802-3.0.orig/src/history.c
|
|
+++ libedit-20110802-3.0/src/history.c
|
|
@@ -741,7 +741,7 @@ history_load(TYPE(History) *h, const cha
|
|
static ct_buffer_t conv;
|
|
#endif
|
|
|
|
- if ((fp = fopen(fname, "r")) == NULL)
|
|
+ if ((fp = fopen(fname, "re")) == NULL)
|
|
return i;
|
|
|
|
if ((line = fgetln(fp, &sz)) == NULL)
|
|
@@ -802,7 +802,7 @@ history_save(TYPE(History) *h, const cha
|
|
static ct_buffer_t conv;
|
|
#endif
|
|
|
|
- if ((fp = fopen(fname, "w")) == NULL)
|
|
+ if ((fp = fopen(fname, "we")) == NULL)
|
|
return -1;
|
|
|
|
if (fchmod(fileno(fp), S_IRUSR|S_IWUSR) == -1)
|