msdosfs: Never allocate clusters outside the volume
authorsf <sf@openbsd.org>
Sun, 30 Apr 2023 17:16:36 +0000 (17:16 +0000)
committersf <sf@openbsd.org>
Sun, 30 Apr 2023 17:16:36 +0000 (17:16 +0000)
commit73083da752da6a7fdb69d579c190ade9af2d2e18
tree7ede5e27a393ac26646cfc6220988f2852dd8416
parent224b35ba5c59672e11a44326d5bf815cc5cacc61
msdosfs: Never allocate clusters outside the volume

- Assert that usemap_alloc() and usemap_free() cluster number argument
  is valid.
- In chainlength(), return 0 if cluster start is after the max cluster.
- In chainlength(), cut the calculated cluster chain length at the max
  cluster.

Adapted from FreeBSD commit 097a1d5fbb7990980f8f806c6878537c964adf32

ok miod@
sys/msdosfs/msdosfs_fat.c