Module Name: src
Committed By: christos
Date: Thu Feb 10 01:49:52 UTC 2011
Modified Files:
src/sys/fs/hfs: hfs_vnops.c
Log Message:
PR/44523: Taylor R Campbell: mount_hfs badly handles file names with slashes
in them, encode them as colons. XXX: Should encode : as :: too?
To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/fs/hfs/hfs_vnops.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/fs/hfs/hfs_vnops.c
diff -u src/sys/fs/hfs/hfs_vnops.c:1.20 src/sys/fs/hfs/hfs_vnops.c:1.21
--- src/sys/fs/hfs/hfs_vnops.c:1.20 Sun Feb 6 22:03:16 2011
+++ src/sys/fs/hfs/hfs_vnops.c Wed Feb 9 20:49:51 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: hfs_vnops.c,v 1.20 2011/02/07 03:03:16 jakllsch Exp $ */
+/* $NetBSD: hfs_vnops.c,v 1.21 2011/02/10 01:49:51 christos Exp $ */
/*-
* Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hfs_vnops.c,v 1.20 2011/02/07 03:03:16 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hfs_vnops.c,v 1.21 2011/02/10 01:49:51 christos Exp $");
#ifdef _KERNEL_OPT
#include "opt_ipsec.h"
@@ -408,15 +408,20 @@
*vpp = vdp;
} else {
hfs_callback_args cbargs;
- uint8_t len;
+ uint8_t len, ni;
hfslib_init_cbargs(&cbargs);
/* XXX: when decomposing, string could grow
and we have to handle overflow */
- unicn = malloc(cnp->cn_namelen*sizeof(unicn[0]), M_TEMP, M_WAITOK);
+ unicn = malloc(cnp->cn_namelen * sizeof(unicn[0]),
+ M_TEMP, M_WAITOK);
len = utf8_to_utf16(unicn, cnp->cn_namelen,
cnp->cn_nameptr, cnp->cn_namelen, 0, NULL);
+ /* XXX: perhaps check for colons too, and encode them? */
+ for (ni = 0; ni < len; ni++)
+ if (unicn[ni] == (unichar_t)'/')
+ unicn[ni] = (unichar_t)':';
/* XXX: check conversion errors? */
if (hfslib_make_catalog_key(VTOH(vdp)->h_rec.u.cnid, len, unicn,
&key) == 0) {
@@ -879,7 +884,7 @@
off_t bufoff; /* offset in buffer relative to start of dirents */
uint32_t numchildren;
uint32_t curchild; /* index of child we are stuffing into dirent */
- size_t namlen;
+ size_t namlen, ni;
int error;
int i; /* dummy variable */
@@ -927,6 +932,10 @@
/* XXX: how to handle name too long? */
continue;
}
+ /* XXX: perhaps check for colons too, and encode them? */
+ for (ni = 0; ni < namlen; ni++)
+ if (curent.d_name[ni] == '/')
+ curent.d_name[ni] = ':';
curent.d_namlen = namlen;
curent.d_reclen = _DIRENT_SIZE(&curent);