Changeset 95afd72 in mainline
- Timestamp:
- 2011-06-03T21:51:10Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 911ee54
- Parents:
- d7c3367
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext2/libext2_directory.c
rd7c3367 r95afd72 40 40 #include <assert.h> 41 41 42 static int ext2_directory_iterator_set(ext2_directory_iterator_t *it, 43 uint32_t block_size); 44 42 45 /** 43 46 * Get inode number for the directory entry … … 126 129 uint32_t next_block_phys_idx; 127 130 uint32_t block_size; 128 uint32_t offset_in_block;129 131 130 132 assert(it->current != NULL); … … 175 177 } 176 178 177 offset_in_block = (it->current_offset + skip) % block_size; 179 it->current_offset += skip; 180 181 return ext2_directory_iterator_set(it, block_size); 182 } 183 184 static int ext2_directory_iterator_set(ext2_directory_iterator_t *it, 185 uint32_t block_size) 186 { 187 uint32_t offset_in_block = it->current_offset % block_size; 188 189 it->current = NULL; 178 190 179 191 /* Ensure proper alignment */ 180 192 if ((offset_in_block % 4) != 0) { 181 it->current = NULL;182 193 return EIO; 183 194 } … … 185 196 /* Ensure that the core of the entry does not overflow the block */ 186 197 if (offset_in_block > block_size - 8) { 187 it->current = NULL; 188 return EIO; 189 } 190 191 it->current = it->current_block->data + offset_in_block; 192 it->current_offset += skip; 198 return EIO; 199 } 200 201 ext2_directory_entry_ll_t *entry = it->current_block->data + offset_in_block; 193 202 194 203 /* Ensure that the whole entry does not overflow the block */ 195 skip = ext2_directory_entry_ll_get_entry_length(it->current); 196 if (offset_in_block + skip > block_size) { 197 it->current = NULL; 204 uint16_t length = ext2_directory_entry_ll_get_entry_length(entry); 205 if (offset_in_block + length > block_size) { 198 206 return EIO; 199 207 } … … 201 209 /* Ensure the name length is not too large */ 202 210 if (ext2_directory_entry_ll_get_name_length(it->fs->superblock, 203 it->current) > skip-8) {204 it->current = NULL;205 return EIO;206 }207 211 entry) > length-8) { 212 return EIO; 213 } 214 215 it->current = entry; 208 216 return EOK; 209 217 }
Note:
See TracChangeset
for help on using the changeset viewer.