summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsf <sf@openbsd.org>2017-08-14 22:43:56 +0000
committersf <sf@openbsd.org>2017-08-14 22:43:56 +0000
commitd3889036268468cdffd3fc47032af381adf0d100 (patch)
tree3145d1d68d1c03431b287be59756c41e88793ad0
parentTry for consistency in sizeof() usage. (diff)
downloadwireguard-openbsd-d3889036268468cdffd3fc47032af381adf0d100.tar.xz
wireguard-openbsd-d3889036268468cdffd3fc47032af381adf0d100.zip
msdofs: Add new CLUST_END constant
Add new CLUST_END and use it as parameter to pcbmap() when searching for end cluster, instead of explicitly passing 0xffff. This fixes potential problem for FAT32, where cluster number may be legally bigger than 0xffff. Also change clusteralloc() so that fillwith is not explicitly passed by caller anymore (there is no need to use anything other than CLUST_EOFE). From NetBSD commit by jdolecek@NetBSD.org ok tb@ mpi@
-rw-r--r--sys/msdosfs/msdosfs_denode.c4
-rw-r--r--sys/msdosfs/msdosfs_fat.c9
-rw-r--r--sys/msdosfs/msdosfs_vnops.c4
3 files changed, 9 insertions, 8 deletions
diff --git a/sys/msdosfs/msdosfs_denode.c b/sys/msdosfs/msdosfs_denode.c
index 018d4744cf7..db2dce6257b 100644
--- a/sys/msdosfs/msdosfs_denode.c
+++ b/sys/msdosfs/msdosfs_denode.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: msdosfs_denode.c,v 1.58 2017/04/20 14:13:00 visa Exp $ */
+/* $OpenBSD: msdosfs_denode.c,v 1.59 2017/08/14 22:43:56 sf Exp $ */
/* $NetBSD: msdosfs_denode.c,v 1.23 1997/10/17 11:23:58 ws Exp $ */
/*-
@@ -324,7 +324,7 @@ retry:
nvp->v_type = VDIR;
if (ldep->de_StartCluster != MSDOSFSROOT) {
- error = pcbmap(ldep, 0xffff, 0, &size, 0);
+ error = pcbmap(ldep, CLUST_END, 0, &size, 0);
if (error == E2BIG) {
ldep->de_FileSize = de_cn2off(pmp, size);
error = 0;
diff --git a/sys/msdosfs/msdosfs_fat.c b/sys/msdosfs/msdosfs_fat.c
index 5dcee74223a..9e4675fa7e5 100644
--- a/sys/msdosfs/msdosfs_fat.c
+++ b/sys/msdosfs/msdosfs_fat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: msdosfs_fat.c,v 1.29 2017/08/13 23:36:27 sf Exp $ */
+/* $OpenBSD: msdosfs_fat.c,v 1.30 2017/08/14 22:43:56 sf Exp $ */
/* $NetBSD: msdosfs_fat.c,v 1.26 1997/10/17 11:24:02 ws Exp $ */
/*-
@@ -714,11 +714,12 @@ chainalloc(struct msdosfsmount *pmp, uint32_t start, uint32_t count,
*/
int
clusteralloc(struct msdosfsmount *pmp, uint32_t start, uint32_t count,
- uint32_t fillwith, uint32_t *retcluster, uint32_t *got)
+ uint32_t *retcluster, uint32_t *got)
{
uint32_t idx;
uint32_t len, newst, foundl, cn, l;
uint32_t foundcn = 0; /* XXX: foundcn could be used uninitialized */
+ uint32_t fillwith = CLUST_EOFE;
u_int map;
#ifdef MSDOSFS_DEBUG
@@ -949,7 +950,7 @@ extendfile(struct denode *dep, uint32_t count, struct buf **bpp, uint32_t *ncp,
if (dep->de_fc[FC_LASTFC].fc_frcn == FCE_EMPTY &&
dep->de_StartCluster != 0) {
fc_lfcempty++;
- error = pcbmap(dep, 0xffff, 0, &cn, 0);
+ error = pcbmap(dep, CLUST_END, 0, &cn, 0);
/* we expect it to return E2BIG */
if (error != E2BIG)
return (error);
@@ -976,7 +977,7 @@ extendfile(struct denode *dep, uint32_t count, struct buf **bpp, uint32_t *ncp,
cn = 0;
else
cn = dep->de_fc[FC_LASTFC].fc_fsrcn + 1;
- error = clusteralloc(pmp, cn, count, CLUST_EOFE, &cn, &got);
+ error = clusteralloc(pmp, cn, count, &cn, &got);
if (error)
return (error);
diff --git a/sys/msdosfs/msdosfs_vnops.c b/sys/msdosfs/msdosfs_vnops.c
index 4d50507c27d..8452e9be80c 100644
--- a/sys/msdosfs/msdosfs_vnops.c
+++ b/sys/msdosfs/msdosfs_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: msdosfs_vnops.c,v 1.115 2017/06/13 18:13:18 sf Exp $ */
+/* $OpenBSD: msdosfs_vnops.c,v 1.116 2017/08/14 22:43:56 sf Exp $ */
/* $NetBSD: msdosfs_vnops.c,v 1.63 1997/10/17 11:24:19 ws Exp $ */
/*-
@@ -1305,7 +1305,7 @@ msdosfs_mkdir(void *v)
/*
* Allocate a cluster to hold the about to be created directory.
*/
- error = clusteralloc(pmp, 0, 1, CLUST_EOFE, &newcluster, NULL);
+ error = clusteralloc(pmp, 0, 1, &newcluster, NULL);
if (error)
goto bad2;