Page MenuHomeFreeBSD

Tighten FAT checks and fix off-by-one error in corner case.
ClosedPublic

Authored by delphij on Jan 7 2020, 5:32 AM.
Tags
None
Referenced Files
F105850612: D23065.diff
Sat, Dec 21, 3:56 PM
Unknown Object (File)
Tue, Nov 26, 11:48 AM
Unknown Object (File)
Nov 5 2024, 11:11 AM
Unknown Object (File)
Sep 20 2024, 9:27 AM
Unknown Object (File)
Sep 15 2024, 5:02 PM
Unknown Object (File)
Sep 12 2024, 7:29 PM
Unknown Object (File)
Sep 7 2024, 12:34 PM
Unknown Object (File)
Sep 4 2024, 7:11 AM
Subscribers

Details

Summary

Tighten FAT checks and fix off-by-one error in corner case.

fat.c:

  • readfat:
    1. Only truncate out-of-range cluster pointers (1, or greater than NumClusters but smaller than CLUST_RSRVD), as the current cluster may contain some data. We can't fix reserved cluster pointers at this pass, because we do no know the potential cluster preceding it.
    2. Accept valid cluster for head bitmap. This is a no-op, and mainly to improve code readability, because the 1 is already handled in the previous else if block.
  • truncate_at: absorbed into checkchain.
  • checkchain: save the previous node we have traversed in case that we have a chain that ends with a special (>= CLUST_RSRVD) cluster, or is free. In these cases, we need to truncate at the cluster preceeding the current cluster, as the current cluster contains a marker instead of a next pointer and can not be changed to CLUST_EOF (the else case can happen if the user answered "no" at some point in readfat()).
  • clearchain: correct the iterator for next cluster so that we dont stop after clearing the first cluster.
  • checklost: If checkchain() thinks the chain have no cluster, it doesn't make sense to reconnect it, so don't bother asking.
Test Plan

Test with various disk images with abnormal chain planted

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable