ClusterOffset actually needs to be able to be negative.
This commit is contained in:
parent
413e395095
commit
d8015429ba
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
__RCSID("$NetBSD: boot.c,v 1.16 2014/07/07 19:04:37 christos Exp $");
|
__RCSID("$NetBSD: boot.c,v 1.17 2014/11/03 18:55:04 jakllsch Exp $");
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -184,7 +184,7 @@ readboot(int dosfs, struct bootblock *boot)
|
||||||
return FSFATAL;
|
return FSFATAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
boot->ClusterOffset = (boot->RootDirEnts * 32 + boot->BytesPerSec - 1)
|
boot->ClusterOffset = (int)(boot->RootDirEnts * 32 + boot->BytesPerSec - 1)
|
||||||
/ boot->BytesPerSec
|
/ boot->BytesPerSec
|
||||||
+ boot->ResSectors
|
+ boot->ResSectors
|
||||||
+ boot->FATs * boot->FATsecs
|
+ boot->FATs * boot->FATsecs
|
||||||
|
@ -205,8 +205,8 @@ readboot(int dosfs, struct bootblock *boot)
|
||||||
boot->NumSectors = boot->HugeSectors;
|
boot->NumSectors = boot->HugeSectors;
|
||||||
boot->NumClusters = (boot->NumSectors - boot->ClusterOffset) / boot->SecPerClust;
|
boot->NumClusters = (boot->NumSectors - boot->ClusterOffset) / boot->SecPerClust;
|
||||||
|
|
||||||
if (boot->ClusterOffset > boot->NumSectors) {
|
if (boot->ClusterOffset > (intmax_t)boot->NumSectors) {
|
||||||
pfatal("Cluster offset too large (%u clusters)\n",
|
pfatal("Cluster offset too large (%d sectors)\n",
|
||||||
boot->ClusterOffset);
|
boot->ClusterOffset);
|
||||||
return FSFATAL;
|
return FSFATAL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: dosfs.h,v 1.6 2008/06/13 20:46:09 martin Exp $ */
|
/* $NetBSD: dosfs.h,v 1.7 2014/11/03 18:55:04 jakllsch Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 1995, 1996, 1997 Wolfgang Solfrank
|
* Copyright (C) 1995, 1996, 1997 Wolfgang Solfrank
|
||||||
|
@ -70,7 +70,7 @@ struct bootblock {
|
||||||
u_int32_t NumSectors; /* how many sectors are there */
|
u_int32_t NumSectors; /* how many sectors are there */
|
||||||
u_int32_t FATsecs; /* how many sectors are in FAT */
|
u_int32_t FATsecs; /* how many sectors are in FAT */
|
||||||
u_int32_t NumFatEntries; /* how many entries really are there */
|
u_int32_t NumFatEntries; /* how many entries really are there */
|
||||||
u_int ClusterOffset; /* at what sector would sector 0 start */
|
int ClusterOffset; /* at what sector would sector 0 start */
|
||||||
u_int ClusterSize; /* Cluster size in bytes */
|
u_int ClusterSize; /* Cluster size in bytes */
|
||||||
|
|
||||||
/* Now some statistics: */
|
/* Now some statistics: */
|
||||||
|
|
Loading…
Reference in New Issue