Fix a problem in previous: we can't blindly assume that we have
wincnt entries available at the offset the file has been found. If the dos directory entry is not preceded by appropriate number of long name entries (happens e.g. when the filesystem is corrupted, or when the filename complies to DOS rules and doesn't use any long name entry), we would overwrite random directory entries. There are still some problems, the whole thing has to be revisited and solved right.
This commit is contained in:
parent
803d0b1a4b
commit
f759642ae2
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: msdosfs_lookup.c,v 1.43 1999/11/05 16:49:15 jdolecek Exp $ */
|
||||
/* $NetBSD: msdosfs_lookup.c,v 1.44 1999/11/05 21:33:21 jdolecek Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
|
||||
|
@ -111,7 +111,7 @@ msdosfs_lookup(v)
|
|||
int flags;
|
||||
int nameiop = cnp->cn_nameiop;
|
||||
int wincnt = 1;
|
||||
int chksum = -1;
|
||||
int chksum = -1, chksum_ok;
|
||||
int olddos = 1;
|
||||
|
||||
cnp->cn_flags &= ~PDIRUNLOCK;
|
||||
|
@ -288,7 +288,8 @@ msdosfs_lookup(v)
|
|||
/*
|
||||
* Check for a checksum or name match
|
||||
*/
|
||||
if (chksum != winChksum(dep->deName)
|
||||
chksum_ok = (chksum == winChksum(dep->deName));
|
||||
if (!chksum_ok
|
||||
&& (!olddos || memcmp(dosfilename, dep->deName, 11))) {
|
||||
chksum = -1;
|
||||
continue;
|
||||
|
@ -303,7 +304,21 @@ msdosfs_lookup(v)
|
|||
* this lookup.
|
||||
*/
|
||||
dp->de_fndoffset = diroff;
|
||||
dp->de_fndcnt = wincnt - 1;
|
||||
if (chksum_ok && nameiop == RENAME) {
|
||||
/*
|
||||
* Target had correct long name
|
||||
* directory entries, reuse them
|
||||
* as needed.
|
||||
*/
|
||||
dp->de_fndcnt = wincnt - 1;
|
||||
} else {
|
||||
/*
|
||||
* Long name directory entries
|
||||
* not present or corrupt, can only
|
||||
* reuse dos directory entry.
|
||||
*/
|
||||
dp->de_fndcnt = 0;
|
||||
}
|
||||
|
||||
goto found;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue