1
1

* main.c (main): Use O_TRUNC when opening the file to write the

last working directory.  Fix segmentation fault when exiting
while on VFS.
* util.c (mc_mkstemps): Use O_TRUNC to open temporary files.
Этот коммит содержится в:
Pavel Roskin 2002-11-01 20:24:07 +00:00
родитель 64b97da9b7
Коммит db31e4b3c4
3 изменённых файлов: 20 добавлений и 10 удалений

Просмотреть файл

@ -1,3 +1,10 @@
2002-11-01 Pavel Roskin <proski@gnu.org>
* main.c (main): Use O_TRUNC when opening the file to write the
last working directory. Fix segmentation fault when exiting
while on VFS.
* util.c (mc_mkstemps): Use O_TRUNC to open temporary files.
2002-10-31 Andrew V. Samoilov <sav@bcs.zp.ua>
* view.c (normal_search) [HAVE_CHARSET]: Fix segmentation fault

Просмотреть файл

@ -2527,10 +2527,11 @@ main (int argc, char *argv[])
/* On NT, home_dir is malloced */
g_free (home_dir);
#endif
if (last_wd_file && !print_last_revert && !edit_one_file
&& !view_one_file) {
int last_wd_fd = open (last_wd_file, O_WRONLY | O_CREAT | O_EXCL,
S_IRUSR | S_IWUSR);
if (last_wd_file && last_wd_string && !print_last_revert
&& !edit_one_file && !view_one_file) {
int last_wd_fd =
open (last_wd_file, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL,
S_IRUSR | S_IWUSR);
if (last_wd_fd != -1) {
write (last_wd_fd, last_wd_string, strlen (last_wd_string));

Просмотреть файл

@ -1193,7 +1193,8 @@ concat_dir_and_file (const char *dir, const char *file)
* Result:
* handle of the open file or -1 if couldn't open any.
*/
int mc_mkstemps(char **pname, const char *prefix, const char *suffix)
int
mc_mkstemps (char **pname, const char *prefix, const char *suffix)
{
static const char letters[]
= "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
@ -1204,7 +1205,7 @@ int mc_mkstemps(char **pname, const char *prefix, const char *suffix)
char *XXXXXX;
int count;
if (strchr(prefix, PATH_SEP) == NULL) {
if (strchr (prefix, PATH_SEP) == NULL) {
/* Add prefix first to find the position of XXXXXX */
tmpbase = concat_dir_and_file (mc_tmpdir (), prefix);
} else {
@ -1214,7 +1215,7 @@ int mc_mkstemps(char **pname, const char *prefix, const char *suffix)
tmpname = g_strconcat (tmpbase, "XXXXXX", suffix, NULL);
*pname = tmpname;
XXXXXX = &tmpname[strlen (tmpbase)];
g_free(tmpbase);
g_free (tmpbase);
/* Get some more or less random data. */
gettimeofday (&tv, NULL);
@ -1237,15 +1238,16 @@ int mc_mkstemps(char **pname, const char *prefix, const char *suffix)
v /= 62;
XXXXXX[5] = letters[v % 62];
fd = open (tmpname, O_RDWR|O_CREAT|O_EXCL, 0600);
fd = open (tmpname, O_RDWR | O_CREAT | O_TRUNC | O_EXCL,
S_IRUSR | S_IWUSR);
if (fd >= 0) {
/* Successfully created. */
return fd;
}
/* This is a random value. It is only necessary that the next
TMP_MAX values generated by adding 7777 to VALUE are different
with (module 2^32). */
TMP_MAX values generated by adding 7777 to VALUE are different
with (module 2^32). */
value += 7777;
}