Commit 18c52557 authored by Paul Eggert's avatar Paul Eggert

* fileio.c: Integer overflow issues with file modes.

(Fset_file_modes, auto_save_1): Don't assume EMACS_INT fits in int.
parent caeeedc1
2011-07-18 Paul Eggert <eggert@cs.ucla.edu>
* fileio.c: Integer overflow issues with file modes.
(Fset_file_modes, auto_save_1): Don't assume EMACS_INT fits in int.
* charset.c (read_hex): New arg OVERFLOW. All uses changed.
Remove unreachable code.
(read_hex, load_charset_map_from_file): Check for integer overflow.
......
......@@ -2893,7 +2893,7 @@ symbolic notation, like the `chmod' command from GNU Coreutils. */)
encoded_absname = ENCODE_FILE (absname);
if (chmod (SSDATA (encoded_absname), XINT (mode)) < 0)
if (chmod (SSDATA (encoded_absname), XINT (mode) & 07777) < 0)
report_file_error ("Doing chmod", Fcons (absname, Qnil));
return Qnil;
......@@ -5095,11 +5095,11 @@ auto_save_1 (void)
{
if (stat (SSDATA (BVAR (current_buffer, filename)), &st) >= 0)
/* But make sure we can overwrite it later! */
auto_save_mode_bits = st.st_mode | 0600;
auto_save_mode_bits = (st.st_mode | 0600) & 0777;
else if ((modes = Ffile_modes (BVAR (current_buffer, filename)),
INTEGERP (modes)))
/* Remote files don't cooperate with stat. */
auto_save_mode_bits = XINT (modes) | 0600;
auto_save_mode_bits = (XINT (modes) | 0600) & 0777;
}
return
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment