File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -143,8 +143,10 @@ static void iso9660_cache_root(struct volume *vol,
143143
144144 * root_size = pv .root .extent_size .little ;
145145
146- // Validate root directory size to prevent memory exhaustion
147- if (* root_size == 0 || * root_size > ISO9660_MAX_DIR_SIZE ) {
146+ // Validate root directory size to prevent memory exhaustion, and require
147+ // sector alignment so directory-traversal sector-skip arithmetic is sound.
148+ if (* root_size == 0 || * root_size > ISO9660_MAX_DIR_SIZE
149+ || * root_size % ISO9660_SECTOR_SIZE != 0 ) {
148150 panic (false, "ISO9660: Invalid root directory size" );
149151 }
150152
@@ -490,8 +492,11 @@ struct file_handle *iso9660_open(struct volume *vol, const char *path) {
490492 pmm_free (current , current_size );
491493 }
492494
493- // Validate directory size to prevent memory exhaustion
494- if (next_size == 0 || next_size > ISO9660_MAX_DIR_SIZE ) {
495+ // Validate directory size to prevent memory exhaustion, and require
496+ // sector alignment so directory-traversal sector-skip arithmetic is
497+ // sound.
498+ if (next_size == 0 || next_size > ISO9660_MAX_DIR_SIZE
499+ || next_size % ISO9660_SECTOR_SIZE != 0 ) {
495500 pmm_free (ret , sizeof (struct iso9660_file_handle ));
496501 return NULL ;
497502 }
You can’t perform that action at this time.
0 commit comments