--- a/lib/ext2fs/inode.c 2007-06-20 13:55:52.000000000 +0200 +++ b/lib/ext2fs/inode.c 2007-06-20 14:11:15.000000000 +0200 @@ -771,6 +771,10 @@ errcode_t ext2fs_get_blocks(ext2_filsys retval = ext2fs_read_inode(fs, ino, &inode); if (retval) return retval; + if (LINUX_S_ISCHR(inode.i_mode) || LINUX_S_ISBLK(inode.i_mode) || + (LINUX_S_ISLNK(inode.i_mode) && + ext2fs_inode_data_blocks(fs, &inode) == 0)) + return EXT2_ET_INVAL_INODE_TYPE; for (i=0; i < EXT2_N_BLOCKS; i++) blocks[i] = inode.i_block[i]; return 0; --- a/lib/ext2fs/ext2_err.et.in 2007-06-20 14:09:18.000000000 +0200 +++ b/lib/ext2fs/ext2_err.et.in 2007-06-20 14:11:25.000000000 +0200 @@ -296,5 +296,8 @@ ec EXT2_ET_RESIZE_INODE_CORRUPT, ec EXT2_ET_SET_BMAP_NO_IND, "Missing indirect block not present" +ec EXT2_ET_INVAL_INODE_TYPE, + "Invalid inode type for the operation." + end