1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-29 00:31:01 -08:00
Commit graph

960 commits

Author SHA1 Message Date
Chong Yidong
fa74b241a3 Document SELinux support functions in Lisp manual.
* doc/lispref/backups.texi (Making Backups): Return value of backup-buffer is
changed.

* doc/lispref/files.texi (File Attributes): Document file-selinux-context.
(Changing Files): Link to it.
(Changing Files): Document set-file-selinux-context.

* fileio.c (Ffile_selinux_context, Fset_file_selinux_context):
Doc fix.
2012-02-25 17:07:23 +08:00
Chong Yidong
a59225b146 Update Files chapter in Lisp manual.
* doc/lispref/files.texi (Files): Mention magic file names as arguments.
(Reading from Files): Copyedits.
(File Attributes): Mention how to change file modes.
(Changing Files): Use standard "file permissions" terminology.
Add xref to File Attributes node.
(Locating Files): Document locate-user-emacs-file.
(Unique File Names): Recommend against using make-temp-name.

* src/buffer.c (Fget_file_buffer): Protect against invalid file
handler return value.

* src/fileio.c (Vfile_name_handler_alist): Doc fix.
2012-02-21 21:24:48 +08:00
Chong Yidong
2375c96a71 Protect fileio.c primitives against invalid file handler return values.
* src/fileio.c (Ffile_name_directory, Ffile_name_nondirectory)
(Funhandled_file_name_directory, Ffile_name_as_directory)
(Fdirectory_file_name, Fexpand_file_name)
(Fsubstitute_in_file_name): Protect against invalid file
handler return values.

Fixes: debbugs:10845
2012-02-19 17:58:23 +08:00
Paul Eggert
9a0115abd1 Merge from trunk. 2012-01-07 11:51:13 -08:00
Glenn Morris
acaf905b11 Add 2012 to FSF copyright years for Emacs files 2012-01-05 01:46:05 -08:00
Paul Eggert
09450bae84 emacs: fix an auto-save permissions race condition
* fileio.c (auto_saving_dir_umask): New static var.
(Fmake_directory_internal): Use it.
(do_auto_save_make_dir): Set it, instead of invoking chmod after
creating the directory.  The old code temporarily assigns
too-generous permissions to the directory.
(do_auto_save_eh): Clear it.
(Fdo_auto_save): Catch all errrors, not just file errors, so
that the var is always cleared.
2011-12-29 12:44:31 -08:00
Ken Brown
e1b01a3a53 * src/fileio.c (check_writable) [CYGWIN]: Return non-zero if UID or
GID is unknown (Bug#10257).
2011-12-17 12:00:49 -05:00
Paul Eggert
fa46310344 Spelling fixes. 2011-12-05 00:55:25 -08:00
Stefan Monnier
0068070eb0 * src/fileio.c (Finsert_file_contents): Move after-change-function call
to before the "handled:" label, since all "goto handled" appear in
cases where the *-change-functions have already been properly called.

Fixes: debbugs:10117
2011-12-01 15:19:38 -05:00
Paul Eggert
83aca1cb69 * fileio.c (Finsert_file_contents): Undo previous change.
See <http://lists.gnu.org/archive/html/emacs-diffs/2011-11/msg00265.html>.
2011-11-26 13:40:41 -08:00
Paul Eggert
5b76caa476 Rename locals to avoid shadowing.
* fileio.c (Finsert_file_contents):
Rename inner 'gcpro1' to 'inner_gcpro1' to avoid shadowing.
* process.c (wait_reading_process_output):
Rename inner 'proc' to 'p' to avoid shadowing.
Indent for consistency with usual Emacs style.
2011-11-25 23:42:44 -08:00
Paul Eggert
ee7683ebb7 Spelling fixes. 2011-11-22 23:03:56 -08:00
Stefan Monnier
a5bb9bd3a8 * src/fileio.c (Finsert_file_contents): Add missing gcpro1 variable.
Suggested by Dmitry Antipov <dmantipov@yandex.ru>.
2011-11-19 23:34:32 -05:00
Paul Eggert
e1dbe924b5 Spelling fixes. 2011-11-19 18:29:42 -08:00
Paul Eggert
5396468298 Spelling fixes. 2011-11-19 01:18:31 -08:00
Paul Eggert
4222c55da7 * buffer.h (struct buffer): Use time_t, not int, for a time stamp.
This fixes a Y2038 bug on 64-bit hosts.
* buffer.c (reset_buffer):
* fileio.c (Fdo_auto_save, Fset_buffer_auto_saved)
(Fclear_buffer_auto_save_failure):
Use 0, not -1, to represent an unset failure time, since time_t
might not be signed.
2011-09-30 13:22:01 -07:00
Paul Eggert
e5e9d610c9 * fileio.c: Report proper errno when syscall falls.
(Finsert_file_contents): Save and restore errno,
so that report_file_error outputs the correct diagnostic.
(Fwrite_region) [CLASH_DETECTION]: Likewise.
2011-09-18 01:34:09 -07:00
Stefan Monnier
2ba8e00888 * src/fileio.c (Finsert_file_contents): Don't assume beg_offset is 0. 2011-09-11 22:22:22 -04:00
Lars Magne Ingebrigtsen
9d1d6e68a4 Clarify slightly the last checkin. 2011-09-11 16:49:24 +02:00
Lars Magne Ingebrigtsen
1c4d7f3d29 (Fvisited_file_modtime): Document `(-1 65535)' as a value for non-existent files. 2011-09-11 16:46:38 +02:00
Eli Zaretskii
b885bf36cf Fix bug #9139 with revisiting non-existent files.
src/fileio.c (Finsert_file_contents): If the file cannot be opened,
 set its "size" to -1.  This will set the modtime_size field of
 the corresponding buffer to -1, which is what
 verify-visited-file-modtime expects for files that do not exist.
2011-09-11 01:52:07 -04:00
Juanma Barranquero
5e617bc2b6 Whitespace changes. 2011-09-09 03:06:52 +02:00
Paul Eggert
728f8f0a00 * fileio.c: Fix bugs with large file offsets.
The previous code assumed that file offsets (off_t values) fit in
EMACS_INT variables, which is not true on typical 32-bit hosts.
The code messed up by falsely reporting buffer overflow in cases
such as (insert-file-contents "big" nil 1 2) into an empty buffer
when "big" contains more than 2**29 bytes, even though this
inserts just one byte and does not overflow the buffer.
(Finsert_file_contents): Store file offsets as off_t
values, not as EMACS_INT values.  Check for overflow when
converting between EMACS_INT and off_t.  When checking for
buffer overflow or for overlap, take the offsets into account.
Don't use EMACS_INT for small values where int suffices.
When checking for overlap, fix a typo: ZV was used where
ZV_BYTE was intended.
(Fwrite_region): Don't assume off_t fits into 'long'.
* buffer.h (struct buffer.modtime_size): Now off_t, not EMACS_INT.
2011-09-02 22:23:17 -07:00
Paul Eggert
7403ff044d Merge from trunk. 2011-07-18 23:10:15 -07:00
Paul Eggert
18c5255701 * fileio.c: Integer overflow issues with file modes.
(Fset_file_modes, auto_save_1): Don't assume EMACS_INT fits in int.
2011-07-18 14:08:22 -07:00
Paul Eggert
15e3a074a6 * fileio.c (Fcopy_file) [!MSDOS]: Tighten created file's mask.
This fixes some race conditions on the permissions of any newly
created file.
2011-07-18 14:01:36 -07:00
Paul Eggert
b59b67c56e * fileio.c (Fcopy_file): Adjust mode if fchown fails. (Bug#9002)
If fchown fails to set both uid and gid, try to set just gid,
as that is sometimes allowed.  Adjust the file's mode to eliminate
setuid or setgid bits that are inappropriate if fchown fails.
2011-07-18 10:21:18 -07:00
Paul Eggert
c2216f8e3a Merge from trunk. 2011-07-16 18:33:46 -07:00
Paul Eggert
9e381cdd96 * fileio.c (Fcopy_file): Pacify gcc re fchown. (Bug#9002)
This works around a problem with the previous change to Fcopy_file.
Recent glibc declares fchown with __attribute__((warn_unused_result)),
and without this change, GCC might complain about discarding
fchown's return value.
2011-07-16 18:18:51 -07:00
Paul Eggert
4f8a454745 Merge from trunk. 2011-07-16 17:37:57 -07:00
Paul Eggert
a803145704 * fileio.c (Fcopy_file): Don't diagnose fchown failures.
Fixes: debbugs:9002
2011-07-16 14:53:38 -07:00
Paul Eggert
a81d11a3ef * editfns.c (pWIDE, pWIDElen, signed_wide, unsigned_wide):
Remove, replacing with the new symbols in lisp.h.  All uses changed.
* fileio.c (make_temp_name):
* filelock.c (lock_file_1, lock_file):
* xdisp.c (message_dolog):
Don't assume PRIdMAX etc. works; this isn't portable to pre-C99 hosts.
Use pMd etc. instead.
* lisp.h (printmax_t, uprintmax_t, pMd, pMu): New types and macros,
replacing the pWIDE etc. symbols removed from editfns.c.
2011-07-07 14:52:44 -07:00
Paul Eggert
6e9b2be9e6 * fileio.c (barf_or_query_if_file_exists): Use S_ISDIR.
This is more efficient than Ffile_directory_p and avoids a minor race.
2011-07-04 10:50:12 -07:00
Lars Magne Ingebrigtsen
ad63790719 (barf_or_query_if_file_exists): Make the "File is a directory"
error be more correct.
2011-07-04 16:34:31 +02:00
Lars Magne Ingebrigtsen
c4f2d8d48d * fileio.c (barf_or_query_if_file_exists): Check first if the file
is a directory before asking whether to use the file name
(bug#7564).
2011-07-04 15:44:52 +02:00
Juanma Barranquero
cd3520a41d Move DEFSYM to lisp.h and use everywhere. 2011-06-24 23:25:22 +02:00
Paul Eggert
93f4cf8895 * fileio.c: Fix some integer overflow issues.
(file_name_as_directory, Fexpand_file_name, Fsubstitute_in_file_name):
Don't assume string length fits in int.
(directory_file_name): Don't assume string length fits in long.
(make_temp_name): Don't assume pid fits in int, or that its print
length is less than 20.
2011-06-19 12:06:16 -07:00
Paul Eggert
1c8e352f7e Improve buffer-overflow checking.
* fileio.c (Finsert_file_contents):
* insdel.c (insert_from_buffer_1, replace_range, replace_range_2):
Remove the old (too-loose) buffer overflow checks.
They weren't needed, since make_gap checks for buffer overflow.
* insdel.c (make_gap_larger): Catch buffer overflows that were missed.
The old code merely checked for Emacs fixnum overflow, and relied
on undefined (wraparound) behavior.  The new code avoids undefined
behavior, and also checks for ptrdiff_t and/or size_t overflow.
2011-06-16 14:18:12 -07:00
Paul Eggert
9956144405 * insdel.c, lisp.h (buffer_overflow): New function.
(insert_from_buffer_1, replace_range, replace_range_2):
* insdel.c (make_gap_larger):
* editfns.c (Finsert_char):
* fileio.c (Finsert_file_contents): Use it, to normalize wording.
2011-06-15 23:48:01 -07:00
Paul Eggert
096a9774c8 * fileio.c (emacs_lseek): Work around GCC bug 43772. 2011-06-15 12:29:18 -07:00
Paul Eggert
e69dafade3 * fileio.c: Don't assume EMACS_INT fits in off_t.
(emacs_lseek): New static function.
(Finsert_file_contents, Fwrite_region): Use it.
Use SEEK_SET, SEEK_CUR, SEEK_END as appropriate.
2011-06-14 18:07:35 -07:00
Paul Eggert
327eeec881 * fileio.c (make_temp_name): Omit unnecessary cast to unsigned. 2011-06-12 19:23:58 -07:00
Paul Eggert
be44ca6cd4 Check for overflow when converting integer to cons and back.
* charset.c (Fdefine_charset_internal, Fdecode_char):
Use cons_to_unsigned to catch overflow.
(Fencode_char): Use INTEGER_TO_CONS.
* composite.h (LGLYPH_CODE): Use cons_to_unsigned.
(LGLYPH_SET_CODE): Use INTEGER_TO_CONS.
* data.c (long_to_cons, cons_to_long): Remove.
(cons_to_unsigned, cons_to_signed): New functions.
These signal an error for invalid or out-of-range values.
* dired.c (Ffile_attributes): Use INTEGER_TO_CONS.
* fileio.c (Fset_visited_file_modtime): Use CONS_TO_INTEGER.
* font.c (Ffont_variation_glyphs):
* fontset.c (Finternal_char_font): Use INTEGER_TO_CONS.
* lisp.h: Include <intprops.h>.
(INTEGER_TO_CONS, CONS_TO_INTEGER): New macros.
(cons_to_signed, cons_to_unsigned): New decls.
(long_to_cons, cons_to_long): Remove decls.
* undo.c (record_first_change): Use INTEGER_TO_CONS.
(Fprimitive_undo): Use CONS_TO_INTEGER.
* xfns.c (Fx_window_property): Likewise.
* xselect.c: Include <limits.h>.
(x_own_selection, selection_data_to_lisp_data):
Use INTEGER_TO_CONS.
(x_handle_selection_request, x_handle_selection_clear)
(x_get_foreign_selection, Fx_disown_selection_internal)
(Fx_get_atom_name, x_send_client_event): Use CONS_TO_INTEGER.
(lisp_data_to_selection_data): Use cons_to_unsigned.
(x_fill_property_data): Use cons_to_signed.
Report values out of range.
2011-06-06 01:29:01 -07:00
Paul Eggert
d1f3d2afe1 Check for buffer and string overflow more precisely.
* buffer.h (BUF_BYTES_MAX): New macro.
* lisp.h (STRING_BYTES_MAX): New macro.
* alloc.c (Fmake_string):
* character.c (string_escape_byte8):
* coding.c (coding_alloc_by_realloc):
* doprnt.c (doprnt):
* editfns.c (Fformat):
* eval.c (verror):
Use STRING_BYTES_MAX, not MOST_POSITIVE_FIXNUM,
since they may not be the same number.
* editfns.c (Finsert_char):
* fileio.c (Finsert_file_contents):
Likewise for BUF_BYTES_MAX.
2011-06-05 23:16:12 -07:00
Paul Eggert
7f9bbdbbd6 * fileio.c (Fverify_visited_file_modtime): Avoid time overflow
if b->modtime has its maximal value.
2011-06-05 22:57:31 -07:00
Paul Eggert
84acfcf06b Don't assume time_t can fit into int.
* buffer.h (struct buffer.modtime): Now time_t, not int.
* fileio.c (Fvisited_file_modtime): No need for time_t cast now.
* undo.c (Fprimitive_undo): Use time_t, not int, for time_t value.
2011-06-01 23:15:15 -07:00
Eli Zaretskii
15cbd324fd Lift the MOST_POSITIVE_FIXNUM/4 limitation on visited files (bug#8528).
src/fileio.c (Finsert_file_contents): Don't limit file size to 1/4
 of MOST_POSITIVE_FIXNUM.
 src/coding.c (coding_alloc_by_realloc): Error out if destination
 will grow beyond MOST_POSITIVE_FIXNUM.
 (decode_coding_emacs_mule): Abort if there isn't enough place in
 charbuf for the composition carryover bytes.  Reserve an extra
 space for up to 2 characters produced in a loop.
 (decode_coding_iso_2022): Abort if there isn't enough place in
 charbuf for the composition carryover bytes.
2011-04-29 22:47:29 +03:00
Paul Eggert
dd19b04f04 Fix merge typo. 2011-04-14 13:20:17 -07:00
Paul Eggert
8bd7b8304a Merge from mainline. 2011-04-14 13:16:48 -07:00
Paul Eggert
cd64ea1d0d * lisp.h (INFUN): Remove. Suggested by Dan Nicolaescu in
<http://lists.gnu.org/archive/html/emacs-devel/2011-04/msg00393.html>.
All uses spelled out.
2011-04-14 12:34:42 -07:00