]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix visiting files in /proc/ directory
authorEli Zaretskii <eliz@gnu.org>
Sun, 19 Jan 2025 10:51:18 +0000 (12:51 +0200)
committerEshel Yaron <me@eshelyaron.com>
Mon, 20 Jan 2025 15:58:41 +0000 (16:58 +0100)
* src/fileio.c (Finsert_file_contents): Treat regular files whose
size is reported as zero as if they were special files.  (Bug#75569)

(cherry picked from commit 26c9fbc94dae34fc119828661c71242d80bb33c5)

src/fileio.c

index db7c491e1a199edd4cbf87cac01dca68f7eb9e7e..bf80d71ab5992fdf97b3b627a45480d4d806fbaf 100644 (file)
@@ -4747,10 +4747,11 @@ by calling `format-decode', which see.  */)
       goto handled;
     }
 
-  if (seekable || !NILP (end))
+  /* Don't believe st.st_size if it is zero.  */
+  if ((regular && st.st_size > 0) || (!regular && seekable) || !NILP (end))
     total = end_offset - beg_offset;
   else
-    /* For a special file, all we can do is guess.  */
+    /* For a special file that is not seekable, all we can do is guess.  */
     total = READ_BUF_SIZE;
 
   if (NILP (visit) && total > 0)