From ddbf79104829765cd321c78a0d00e2089704a92c Mon Sep 17 00:00:00 2001 From: syl Date: Mon, 28 Apr 2014 13:08:34 +0000 Subject: [PATCH] Add support for 255 character file names in fuse. from Helg Bredow, thanks! input/OK reyk@ --- lib/libfuse/dict.c | 4 ++-- lib/libfuse/fuse_private.h | 4 ++-- 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 @@ -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 * @@ -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 * @@ -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; -- 2.20.1