aboutsummaryrefslogtreecommitdiffstats
path: root/src/fns.c
diff options
context:
space:
mode:
authorPaul Eggert2017-03-30 11:08:23 -0700
committerPaul Eggert2017-03-30 11:08:42 -0700
commit6ff870218dd4bc015cc4115ceb2febd8d807e57c (patch)
tree67eaa089c0754194e75eea898e24c4a6bcfbe91a /src/fns.c
parent1be3330b31f9c0d0d0f7d25641e8b81c807ca616 (diff)
downloademacs-6ff870218dd4bc015cc4115ceb2febd8d807e57c.tar.gz
emacs-6ff870218dd4bc015cc4115ceb2febd8d807e57c.zip
Some inotify cleanup
This catches some problems with integer overflow and races that I noticed in inotify.c after reviewing the changes installed to fix Bug#26126. * src/fns.c, src/lisp.h (equal_no_quit): Now extern. * src/inotify.c (aspect_to_inotifymask): Check for cycles and for improper lists. (make_lispy_mask, lispy_mask_match_p): Remove. All callers changed to use INTEGER_TO_CONS and CONS_TO_INTEGER. (inotifyevent_to_event, add_watch): Don’t assume watch descriptors and cookies fit in fixnums. (add_watch): Use assoc_no_quit, not Fassoc. Avoid integer overflow in (very!) long-running processes where the Emacs watch ID could overflow. Avoid some duplicate code. (find_descriptor): New function. (remove_descriptor): First arg is now the returned value from find_descriptor, rather than the descriptor. This way, the value can be removed without calling Fdelete, which might quit. Wait until the end (when watch_list is consistent) before signaling any errors. (remove_watch, inotify_callback): Use find_descriptor to avoid the need for Fdelete. (inotify_callback): Use simpler tests for ioctl failure. Free temporary buffer if signaled, and put it on the stack if small. Use ssize_t to index through read results, to avoid a cast. (valid_watch_descriptor): New function, with a tighter check. (Finotify_rm_watch, Finotify_valid_p): Use it. (Finotify_valid_p): Use assoc_no_quit and ass_no_quit instead of Fassoc. Do not assume the first assoc succeeds. * test/src/inotify-tests.el (inotify-valid-p-simple): Add inotify-valid-p tests, some of which dump core without the fixes noted above.
Diffstat (limited to 'src/fns.c')
-rw-r--r--src/fns.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/fns.c b/src/fns.c
index 42e2eecf33e..de7fc1b47fc 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -38,7 +38,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
38 38
39static void sort_vector_copy (Lisp_Object, ptrdiff_t, 39static void sort_vector_copy (Lisp_Object, ptrdiff_t,
40 Lisp_Object *restrict, Lisp_Object *restrict); 40 Lisp_Object *restrict, Lisp_Object *restrict);
41static bool equal_no_quit (Lisp_Object, Lisp_Object);
42enum equal_kind { EQUAL_NO_QUIT, EQUAL_PLAIN, EQUAL_INCLUDING_PROPERTIES }; 41enum equal_kind { EQUAL_NO_QUIT, EQUAL_PLAIN, EQUAL_INCLUDING_PROPERTIES };
43static bool internal_equal (Lisp_Object, Lisp_Object, 42static bool internal_equal (Lisp_Object, Lisp_Object,
44 enum equal_kind, int, Lisp_Object); 43 enum equal_kind, int, Lisp_Object);
@@ -2121,7 +2120,7 @@ of strings. (`equal' ignores text properties.) */)
2121 Use this only on arguments that are cycle-free and not too large and 2120 Use this only on arguments that are cycle-free and not too large and
2122 are not window configurations. */ 2121 are not window configurations. */
2123 2122
2124static bool 2123bool
2125equal_no_quit (Lisp_Object o1, Lisp_Object o2) 2124equal_no_quit (Lisp_Object o1, Lisp_Object o2)
2126{ 2125{
2127 return internal_equal (o1, o2, EQUAL_NO_QUIT, 0, Qnil); 2126 return internal_equal (o1, o2, EQUAL_NO_QUIT, 0, Qnil);