Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/fs/msdosfs We can't depend on dp->d_namlen existing for ...
details: https://anonhg.NetBSD.org/src/rev/d3ed63e754b5
branches: trunk
changeset: 343374:d3ed63e754b5
user: christos <christos%NetBSD.org@localhost>
date: Mon Feb 01 02:59:33 2016 +0000
description:
We can't depend on dp->d_namlen existing for the parts that are used in
makefs(8).
diffstat:
sys/fs/msdosfs/direntry.h | 4 ++--
sys/fs/msdosfs/msdosfs_conv.c | 24 ++++++++++++++++--------
sys/fs/msdosfs/msdosfs_vnops.c | 9 ++++++---
3 files changed, 24 insertions(+), 13 deletions(-)
diffs (130 lines):
diff -r 7b159a3eef67 -r d3ed63e754b5 sys/fs/msdosfs/direntry.h
--- a/sys/fs/msdosfs/direntry.h Mon Feb 01 02:16:48 2016 +0000
+++ b/sys/fs/msdosfs/direntry.h Mon Feb 01 02:59:33 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: direntry.h,v 1.10 2016/01/30 09:59:27 mlelstv Exp $ */
+/* $NetBSD: direntry.h,v 1.11 2016/02/01 02:59:33 christos Exp $ */
/*-
* Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -140,7 +140,7 @@
int winChkName(const unsigned char *un, int unlen, struct winentry *wep,
int chksum, int utf8);
int win2unixfn(struct winentry *wep, struct dirent *dp, int chksum,
- int utf8);
+ uint16_t *namlen, int utf8);
uint8_t winChksum(uint8_t *name);
int winSlotCnt(const unsigned char *un, int unlen, int utf8);
#endif /* _KERNEL || MAKEFS */
diff -r 7b159a3eef67 -r d3ed63e754b5 sys/fs/msdosfs/msdosfs_conv.c
--- a/sys/fs/msdosfs/msdosfs_conv.c Mon Feb 01 02:16:48 2016 +0000
+++ b/sys/fs/msdosfs/msdosfs_conv.c Mon Feb 01 02:59:33 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msdosfs_conv.c,v 1.11 2016/01/30 09:59:27 mlelstv Exp $ */
+/* $NetBSD: msdosfs_conv.c,v 1.12 2016/02/01 02:59:33 christos Exp $ */
/*-
* Copyright (C) 1995, 1997 Wolfgang Solfrank.
@@ -62,7 +62,7 @@
#endif
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_conv.c,v 1.11 2016/01/30 09:59:27 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_conv.c,v 1.12 2016/02/01 02:59:33 christos Exp $");
/*
* System include files.
@@ -1549,7 +1549,8 @@
* Returns the checksum or -1 if impossible
*/
int
-win2unixfn(struct winentry *wep, struct dirent *dp, int chksum, int utf8)
+win2unixfn(struct winentry *wep, struct dirent *dp, int chksum,
+ uint16_t *namlen, int utf8)
{
u_int16_t wn[WIN_CHARS], *p;
u_int8_t buf[WIN_CHARS*3];
@@ -1564,7 +1565,7 @@
*/
if (wep->weCnt & WIN_LAST) {
chksum = wep->weChksum;
- dp->d_namlen = 0;
+ *namlen = 0;
} else if (chksum != wep->weChksum)
chksum = -1;
if (chksum == -1)
@@ -1591,6 +1592,9 @@
*/
len = utf8 ? ucs2utf8str(wn, WIN_CHARS, buf, sizeof(buf)) : ucs2char8str(wn, WIN_CHARS, buf, sizeof(buf));
+ if (len > sizeof(dp->d_name) - 1)
+ return -1;
+
/*
* Prepend name segment to directory entry
*
@@ -1602,12 +1606,16 @@
* are silently discarded. This could also end in multiple
* files using the same (truncated) name.
*/
- dp->d_namlen += len;
- if (dp->d_namlen > sizeof(dp->d_name)-1)
- dp->d_namlen = sizeof(dp->d_name)-1;
- memmove(&dp->d_name[len], &dp->d_name[0], dp->d_namlen - len);
+ *namlen += len;
+ if (*namlen > sizeof(dp->d_name) - 1)
+ *namlen = sizeof(dp->d_name) - 1;
+ memmove(&dp->d_name[len], &dp->d_name[0], *namlen - len);
memcpy(dp->d_name, buf, len);
+#ifdef __NetBSD__
+ dp->d_namlen = *namlen;
+#endif
+
return chksum;
}
diff -r 7b159a3eef67 -r d3ed63e754b5 sys/fs/msdosfs/msdosfs_vnops.c
--- a/sys/fs/msdosfs/msdosfs_vnops.c Mon Feb 01 02:16:48 2016 +0000
+++ b/sys/fs/msdosfs/msdosfs_vnops.c Mon Feb 01 02:59:33 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msdosfs_vnops.c,v 1.94 2016/01/30 09:59:27 mlelstv Exp $ */
+/* $NetBSD: msdosfs_vnops.c,v 1.95 2016/02/01 02:59:33 christos Exp $ */
/*-
* Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.94 2016/01/30 09:59:27 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.95 2016/02/01 02:59:33 christos Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -1394,6 +1394,7 @@
int ncookies = 0, nc = 0;
off_t offset, uio_off;
int chksum = -1;
+ uint16_t namlen;
#ifdef MSDOSFS_DEBUG
printf("msdosfs_readdir(): vp %p, uio %p, cred %p, eofflagp %p\n",
@@ -1541,7 +1542,8 @@
if (pmp->pm_flags & MSDOSFSMNT_SHORTNAME)
continue;
chksum = win2unixfn((struct winentry *)dentp,
- dirbuf, chksum, pmp->pm_flags & MSDOSFSMNT_UTF8);
+ dirbuf, chksum, &namlen,
+ pmp->pm_flags & MSDOSFSMNT_UTF8);
continue;
}
@@ -1584,6 +1586,7 @@
pmp->pm_flags & MSDOSFSMNT_SHORTNAME);
else
dirbuf->d_name[dirbuf->d_namlen] = 0;
+ namlen = dirbuf->d_namlen;
chksum = -1;
dirbuf->d_reclen = _DIRENT_SIZE(dirbuf);
if (uio->uio_resid < dirbuf->d_reclen) {
Home |
Main Index |
Thread Index |
Old Index