@@ -899,9 +899,17 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size,
899
899
goto out ;
900
900
}
901
901
902
- sbi -> record_size = record_size =
903
- boot -> record_size < 0 ? 1 << (- boot -> record_size ) :
904
- (u32 )boot -> record_size << cluster_bits ;
902
+ if (boot -> record_size >= 0 ) {
903
+ record_size = (u32 )boot -> record_size << cluster_bits ;
904
+ } else if (- boot -> record_size <= MAXIMUM_SHIFT_BYTES_PER_MFT ) {
905
+ record_size = 1u << (- boot -> record_size );
906
+ } else {
907
+ ntfs_err (sb , "%s: invalid record size %d." , hint ,
908
+ boot -> record_size );
909
+ goto out ;
910
+ }
911
+
912
+ sbi -> record_size = record_size ;
905
913
sbi -> record_bits = blksize_bits (record_size );
906
914
sbi -> attr_size_tr = (5 * record_size >> 4 ); // ~320 bytes
907
915
@@ -918,9 +926,15 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size,
918
926
goto out ;
919
927
}
920
928
921
- sbi -> index_size = boot -> index_size < 0 ?
922
- 1u << (- boot -> index_size ) :
923
- (u32 )boot -> index_size << cluster_bits ;
929
+ if (boot -> index_size >= 0 ) {
930
+ sbi -> index_size = (u32 )boot -> index_size << cluster_bits ;
931
+ } else if (- boot -> index_size <= MAXIMUM_SHIFT_BYTES_PER_INDEX ) {
932
+ sbi -> index_size = 1u << (- boot -> index_size );
933
+ } else {
934
+ ntfs_err (sb , "%s: invalid index size %d." , hint ,
935
+ boot -> index_size );
936
+ goto out ;
937
+ }
924
938
925
939
/* Check index record size. */
926
940
if (sbi -> index_size < SECTOR_SIZE || !is_power_of_2 (sbi -> index_size )) {
0 commit comments