diff options
author | Sylvestre Gallon <syl@cvs.openbsd.org> | 2014-04-28 13:08:35 +0000 |
---|---|---|
committer | Sylvestre Gallon <syl@cvs.openbsd.org> | 2014-04-28 13:08:35 +0000 |
commit | a130f4a7beb3c01b4333e994c59556a8dda5e14a (patch) | |
tree | e7530c56bb3c6730542148cec2cd863c5c1f8958 | |
parent | 11d5f493d48092db72b9e369918e02733483bac8 (diff) |
Add support for 255 character file names in fuse.
from Helg Bredow, thanks!
input/OK reyk@
-rw-r--r-- | lib/libfuse/dict.c | 4 | ||||
-rw-r--r-- | lib/libfuse/fuse_private.h | 4 | ||||
-rw-r--r-- | lib/libfuse/fuse_subr.c | 12 |
3 files changed, 12 insertions, 8 deletions
diff --git a/lib/libfuse/dict.c b/lib/libfuse/dict.c index a30532b1f1a..dc51c0c2ea6 100644 --- a/lib/libfuse/dict.c +++ b/lib/libfuse/dict.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dict.c,v 1.1 2013/06/03 16:00:50 tedu Exp $ */ +/* $OpenBSD: dict.c,v 1.2 2014/04/28 13:08:34 syl Exp $ */ /* * Copyright (c) 2012 Gilles Chehade <gilles@poolp.org> @@ -26,7 +26,7 @@ #define MAX_DICTKEY_SIZE NAME_MAX struct dictentry { SPLAY_ENTRY(dictentry) entry; - char key[MAX_DICTKEY_SIZE]; + char key[MAX_DICTKEY_SIZE + 1]; void *data; }; diff --git a/lib/libfuse/fuse_private.h b/lib/libfuse/fuse_private.h index af3581be87c..cf6e7b6a6d5 100644 --- a/lib/libfuse/fuse_private.h +++ b/lib/libfuse/fuse_private.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fuse_private.h,v 1.9 2013/12/03 09:59:40 syl Exp $ */ +/* $OpenBSD: fuse_private.h,v 1.10 2014/04/28 13:08:34 syl Exp $ */ /* * Copyright (c) 2013 Sylvestre Gallon <ccna.syl@gmail.com> * @@ -34,7 +34,7 @@ struct fuse_vnode { ino_t ino; ino_t parent; - char path[NAME_MAX]; + char path[NAME_MAX + 1]; struct fuse_dirhandle *fd; SIMPLEQ_ENTRY(fuse_vnode) node; /* for dict */ diff --git a/lib/libfuse/fuse_subr.c b/lib/libfuse/fuse_subr.c index 95ba3293a75..2bcb1b661f0 100644 --- a/lib/libfuse/fuse_subr.c +++ b/lib/libfuse/fuse_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fuse_subr.c,v 1.7 2014/02/05 20:13:58 syl Exp $ */ +/* $OpenBSD: fuse_subr.c,v 1.8 2014/04/28 13:08:34 syl Exp $ */ /* * Copyright (c) 2013 Sylvestre Gallon <ccna.syl@gmail.com> * @@ -29,14 +29,18 @@ alloc_vn(struct fuse *f, const char *path, ino_t ino, ino_t parent) struct fuse_vnode *vn; if ((vn = malloc(sizeof(*vn))) == NULL) { - DPERROR("alloc_vn:"); + DPERROR(__func__); return (NULL); } vn->ino = ino; vn->parent = parent; - strncpy(vn->path, path, NAME_MAX); - vn->path[NAME_MAX - 1] = '\0'; + if (strlcpy(vn->path, path, sizeof(vn->path)) >= sizeof(vn->path)) { + DPRINTF("%s: strlcpy name too long\n", __func__); + free(vn); + return (NULL); + } + if (ino == (ino_t)-1) { f->max_ino++; vn->ino = f->max_ino; |