Whamcloud - gitweb
In ext2ed, if there is a directory entry of length 0,
authorTheodore Ts'o <tytso@mit.edu>
Mon, 30 Sep 2002 04:12:10 +0000 (00:12 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 30 Sep 2002 04:12:10 +0000 (00:12 -0400)
go to the next block, so we don't end up looping forever.

ext2ed/ChangeLog
ext2ed/dir_com.c

index e4152cf..acadc9b 100644 (file)
@@ -1,3 +1,9 @@
+2002-09-30  Theodore Ts'o  <tytso@mit.edu>
+
+       * dir_com.c (search_dir_entries): If there is a directory entry of
+               length 0, go to the next block, so we don't end up looping
+               forever.
+
 2001-09-24  Theodore Tso  <tytso@mit.edu>
 
        * Release of E2fsprogs 1.29
index 74557b7..211a5cf 100644 (file)
@@ -99,8 +99,7 @@ struct struct_file_info search_dir_entries (int (*action) (struct struct_file_in
 {
        struct struct_file_info info;                                           /* Temporary variables used to */
        struct ext2_dir_entry_2 *dir_entry_ptr;                                 /* contain the current search entries */
-       
-       int return_code;
+       int return_code, next;
        
        info=first_file_info;                                                   /* Start from the first entry - Read it */
        low_read (info.buffer,file_system_info.block_size,info.global_block_offset);
@@ -118,8 +117,11 @@ struct struct_file_info search_dir_entries (int (*action) (struct struct_file_in
                dir_entry_ptr=(struct ext2_dir_entry_2 *) (info.buffer+info.dir_entry_offset);
 
                info.dir_entry_num++;
-               info.dir_entry_offset+=dir_entry_ptr->rec_len;
-               info.file_offset+=dir_entry_ptr->rec_len;
+               next = dir_entry_ptr->rec_len;
+               if (!next)
+                       next = file_system_info.block_size - info.dir_entry_offset;
+               info.dir_entry_offset += next;
+               info.file_offset += next;
 
                if (info.file_offset >= info.file_length) break;