diff options
author | Andrea Corallo <akrl@sdf.org> | 2021-03-26 08:06:09 +0100 |
---|---|---|
committer | Andrea Corallo <akrl@sdf.org> | 2021-03-26 08:42:29 +0100 |
commit | 79b8b6ca45ad707d86244882430e275efd95cdb9 (patch) | |
tree | 3c5eeb70ed728b82ba5ac21e716f5e053cc9db20 /src/lread.c | |
parent | c6c7b30e4b46bf0c8ac5e77546d3938e79f14d56 (diff) | |
download | emacs-79b8b6ca45ad707d86244882430e275efd95cdb9.tar.gz |
* Prevent stale eln loading checking file timestamp before load (bug#46617)
* src/lread.c (maybe_swap_for_eln): Add file timestamp check.
(openp): Update 'maybe_swap_for_eln' call sites.
Diffstat (limited to 'src/lread.c')
-rw-r--r-- | src/lread.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/lread.c b/src/lread.c index 56717dba810..e8c257a13cc 100644 --- a/src/lread.c +++ b/src/lread.c @@ -1649,7 +1649,8 @@ directories, make sure the PREDICATE function returns `dir-ok' for them. */) If found replace the content of FILENAME and FD. */ static void -maybe_swap_for_eln (bool no_native, Lisp_Object *filename, int *fd) +maybe_swap_for_eln (bool no_native, Lisp_Object *filename, int *fd, + struct timespec mtime) { #ifdef HAVE_NATIVE_COMP struct stat eln_st; @@ -1686,13 +1687,19 @@ maybe_swap_for_eln (bool no_native, Lisp_Object *filename, int *fd) emacs_close (eln_fd); else { - *filename = eln_name; - emacs_close (*fd); - *fd = eln_fd; - /* Store the eln -> el relation. */ - Fputhash (Ffile_name_nondirectory (eln_name), - src_name, Vcomp_eln_to_el_h); - return; + struct timespec eln_mtime = get_stat_mtime (&eln_st); + if (timespec_cmp (eln_mtime, mtime) >= 0) + { + *filename = eln_name; + emacs_close (*fd); + *fd = eln_fd; + /* Store the eln -> el relation. */ + Fputhash (Ffile_name_nondirectory (eln_name), + src_name, Vcomp_eln_to_el_h); + return; + } + else + emacs_close (eln_fd); } } } @@ -1940,7 +1947,8 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, } else { - maybe_swap_for_eln (no_native, &string, &fd); + maybe_swap_for_eln (no_native, &string, &fd, + get_stat_mtime (&st)); /* We succeeded; return this descriptor and filename. */ if (storeptr) *storeptr = string; @@ -1952,7 +1960,8 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, /* No more suffixes. Return the newest. */ if (0 <= save_fd && ! CONSP (XCDR (tail))) { - maybe_swap_for_eln (no_native, &save_string, &save_fd); + maybe_swap_for_eln (no_native, &save_string, &save_fd, + save_mtime); if (storeptr) *storeptr = save_string; SAFE_FREE (); |