doc/share/security/patches/SA-06:02/ee.patch
Bjoern A. Zeeb 3571e53040 Import FreeBSD Security Advisories and Errata Notices, as well as their
patches for easier mirroring, to eliminate a special copy, to make
www.freebsd.org/security a full copy of security.freebsd.org and be
eventually be the same.

For now files are just sitting there.   The symlinks are missing.

Discussed on:	www (repository location)
Discussed with:	simon (so)
2012-08-15 06:19:40 +00:00

104 lines
2.4 KiB
Diff

Index: usr.bin/ee/ee.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/ee/ee.c,v
retrieving revision 1.32
diff -u -d -r1.32 ee.c
--- usr.bin/ee/ee.c 5 Nov 2004 10:18:05 -0000 1.32
+++ usr.bin/ee/ee.c 1 Jan 2006 22:51:41 -0000
@@ -300,7 +300,7 @@
int quit P_((int noverify));
void edit_abort P_((int arg));
void delete_text P_((void));
-int write_file P_((char *file_name));
+int write_file P_((char *file_name, int warn_if_exists));
int search P_((int display_message));
void search_prompt P_((void));
void del_char P_((void));
@@ -1688,7 +1688,7 @@
cmd_str = cmd_str2 = get_string(file_write_prompt_str, TRUE);
}
tmp_file = resolve_name(cmd_str);
- write_file(tmp_file);
+ write_file(tmp_file, 1);
if (tmp_file != cmd_str)
free(tmp_file);
}
@@ -2395,7 +2395,7 @@
file_name = tmp_file;
}
- if (write_file(file_name))
+ if (write_file(file_name, 1))
{
text_changes = FALSE;
quit(0);
@@ -2472,8 +2472,9 @@
}
int
-write_file(file_name)
+write_file(file_name, warn_if_exists)
char *file_name;
+int warn_if_exists;
{
char cr;
char *tmp_point;
@@ -2483,7 +2484,8 @@
int write_flag = TRUE;
charac = lines = 0;
- if ((in_file_name == NULL) || strcmp(in_file_name, file_name))
+ if (warn_if_exists &&
+ ((in_file_name == NULL) || strcmp(in_file_name, file_name)))
{
if ((temp_fp = fopen(file_name, "r")))
{
@@ -3725,7 +3727,7 @@
{
string = get_string(file_write_prompt_str, TRUE);
tmp_file = resolve_name(string);
- write_file(tmp_file);
+ write_file(tmp_file, 1);
if (tmp_file != string)
free(tmp_file);
free(string);
@@ -3762,7 +3764,7 @@
string = tmp_file;
}
}
- if (write_file(string))
+ if (write_file(string, 1))
{
in_file_name = string;
text_changes = FALSE;
@@ -4375,17 +4377,25 @@
void
ispell_op()
{
- char name[128];
+ char template[128], *name;
char string[256];
- int pid;
+ int fd;
if (restrict_mode())
{
return;
}
- pid = getpid();
- sprintf(name, "/tmp/ee.%d", pid);
- if (write_file(name))
+ (void)sprintf(template, "/tmp/ee.XXXXXXXX");
+ name = mktemp(&template[0]);
+ fd = open(name, O_CREAT | O_EXCL | O_RDWR, 0600);
+ if (fd < 0) {
+ wmove(com_win, 0, 0);
+ wprintw(com_win, create_file_fail_msg, name);
+ wrefresh(com_win);
+ return;
+ }
+ close(fd);
+ if (write_file(name, 0))
{
sprintf(string, "ispell %s", name);
sh_command(string);