88
99#undef DEBUG
1010
11- #define SECTOR_SIZE 512
11+ #define SECTOR_SIZE 512
1212
1313extern void End_code (void );
1414
@@ -117,7 +117,7 @@ uint16_t Input_cmd(SYSREQ far *req)
117117{
118118 int reply ;
119119 uint16_t idx ;
120- uint32_t sector ;
120+ uint32_t sector , sector_max ;
121121 uint8_t far * buf = req -> io .buffer_ptr ;
122122
123123
@@ -129,22 +129,26 @@ uint16_t Input_cmd(SYSREQ far *req)
129129#if 0
130130 dumpHex ((uint8_t far * ) req , req -> length );
131131 consolef ("SECTOR: %i 0x%04x 0x%08lx\n" , req -> length ,
132- req -> io .start_sector , (uint32_t ) req -> io .start_sector_32 );
132+ req -> io .start_sector , (uint32_t ) req -> io .start_sector_32 );
133133#endif
134134
135135 if (req -> length > 22 )
136136 sector = req -> io .start_sector_32 ;
137137 else
138138 sector = req -> io .start_sector ;
139139
140+ if (fn_bpb_table [req -> unit ].num_sectors )
141+ sector_max = fn_bpb_table [req -> unit ].num_sectors ;
142+ else
143+ sector_max = fn_bpb_table [req -> unit ].num_sectors_32 ;
144+
140145#if 0
141146 consolef ("SECTOR: %i 0x%08lx %i\n" , req -> length , sector , req -> io .count );
142147#endif
143148
144149 for (idx = 0 ; idx < req -> io .count ; idx ++ , sector ++ ) {
145- if (fn_bpb_table [req -> unit ].num_sectors && sector >= fn_bpb_table [req -> unit ].num_sectors
146- || sector >= fn_bpb_table [req -> unit ].num_sectors_32 ) {
147- consolef ("FN Invalid sector read %i on %i:\n" , sector , req -> unit );
150+ if (sector >= sector_max ) {
151+ consolef ("FN Invalid sector read %li on %i\n" , sector , req -> unit );
148152 return ERROR_BIT | NOT_FOUND ;
149153 }
150154
@@ -183,7 +187,7 @@ uint16_t Output_cmd(SYSREQ far *req)
183187{
184188 int reply ;
185189 uint16_t idx ;
186- uint32_t sector ;
190+ uint32_t sector , sector_max ;
187191 uint8_t far * buf = req -> io .buffer_ptr ;
188192
189193
@@ -194,19 +198,23 @@ uint16_t Output_cmd(SYSREQ far *req)
194198
195199 if (disk_slots [req -> unit ].mode != MODE_READWRITE )
196200 return ERROR_BIT | WRITE_PROTECT ;
197-
201+
198202 if (req -> length > 22 )
199203 sector = req -> io .start_sector_32 ;
200204 else
201205 sector = req -> io .start_sector ;
202206
207+ if (fn_bpb_table [req -> unit ].num_sectors )
208+ sector_max = fn_bpb_table [req -> unit ].num_sectors ;
209+ else
210+ sector_max = fn_bpb_table [req -> unit ].num_sectors_32 ;
211+
203212#if 0
204213 consolef ("WRITE SECTOR: %i 0x%08lx %i\n" , req -> length , sector , req -> io .count );
205214#endif
206215
207216 for (idx = 0 ; idx < req -> io .count ; idx ++ , sector ++ ) {
208- if (fn_bpb_table [req -> unit ].num_sectors && sector >= fn_bpb_table [req -> unit ].num_sectors
209- || sector >= fn_bpb_table [req -> unit ].num_sectors_32 ) {
217+ if (sector >= sector_max ) {
210218 consolef ("FN Invalid sector write %i on %i:\n" , sector , req -> unit );
211219 return ERROR_BIT | NOT_FOUND ;
212220 }
0 commit comments