diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/drivers/fat.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c index 6f82f5ab36..877beff7f1 100644 --- a/firmware/drivers/fat.c +++ b/firmware/drivers/fat.c | |||
@@ -888,20 +888,21 @@ int fat_read( struct fat_file *file, int sectorcount, void* buf ) | |||
888 | return 0; | 888 | return 0; |
889 | 889 | ||
890 | /* find sequential sectors and read them all at once */ | 890 | /* find sequential sectors and read them all at once */ |
891 | for (i=0; i<sectorcount; i++ ) { | 891 | for (i=0; i<sectorcount && sector>0; i++ ) { |
892 | numsec++; | 892 | numsec++; |
893 | if ( numsec >= fat_bpb.bpb_secperclus ) { | 893 | if ( numsec >= fat_bpb.bpb_secperclus ) { |
894 | cluster = get_next_cluster(cluster); | 894 | cluster = get_next_cluster(cluster); |
895 | if (!cluster) { | 895 | if (!cluster) { |
896 | /* end of file */ | 896 | /* end of file */ |
897 | sector = -1; | 897 | sector = -1; |
898 | break; | ||
899 | } | 898 | } |
900 | 899 | else | |
901 | sector = cluster2sec(cluster); | 900 | { |
902 | if (sector<0) | 901 | sector = cluster2sec(cluster); |
903 | return -1; | 902 | if (sector<0) |
904 | numsec=0; | 903 | return -1; |
904 | numsec=0; | ||
905 | } | ||
905 | } | 906 | } |
906 | else | 907 | else |
907 | sector++; | 908 | sector++; |