commit c180703603f314ef83c39aae5a15c83c72918a64
Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date:   Tue Mar 18 01:58:27 2025 +0100

    ext2fs: Do not try to frob inline data for regular files and directories
    
    Inline data in i_data is only used by symlinks (and apparently some
    device nodes in linux). For regular files and directories we don't store
    data there. This is actually important since otherwise
    
            int fd = open("foo.txt", O_WRONLY|O_CREAT);
            ftruncate(fd, 1024);
            ftruncate(fd, 10);
    
    leads to trying to frob beyond i_data end.

diff --git a/ext2fs/truncate.c b/ext2fs/truncate.c
index 44aab3c7..aa3a5a60 100644
--- a/ext2fs/truncate.c
+++ b/ext2fs/truncate.c
@@ -291,7 +291,9 @@ diskfs_truncate (struct node *node, off_t length)
   if (length >= node->dn_stat.st_size)
     return 0;
 
-  if (! node->dn_stat.st_blocks)
+  if (! node->dn_stat.st_blocks
+      && !S_ISREG (node->dn_stat.st_mode)
+      && !S_ISDIR (node->dn_stat.st_mode))
     /* There aren't really any blocks allocated, so just frob the size.  This
        is true for fast symlinks, and also apparently for some device nodes
        in linux.  */
