• Darrick J. Wong's avatar
    libext2fs: repair side effects when iterating dirents in inline dirs · 8f22fa05
    Darrick J. Wong authored
    
    
    In ext2fs_inline_data_dir_iterate(), we must be very careful to undo
    any modifications we make to the dir_context pointer passed in by the
    caller, because it's entirely possible that the caller will still want
    to do something with the ctx or something inside.
    
    Specifically, ext2fs_dblist_dir_iterate() wants to be able to free
    ctx->buf, and it reuses the ctx for multiple dblist entries.  That
    means that assigning ctx->buf will cause weird crashes at the end of
    dir_iterate().
    
    Since we're being careful with ctx, we might as well handle adding the
    INLINE_DATA flag to ctx->flags for ext2fs_process_dir_block, since the
    dblist caller forgets to unset the flag before reusing the ctx.
    
    This fixes some crashes and valgrind complaints in resize2fs, and is
    necessary for the next patch, which fixes resize2fs not to corrupt
    inline_data filesystems.
    Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
    Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
    8f22fa05
dblist_dir.c 1.9 KB