-/* $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>
#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;
};
-/* $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>
*
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 */
-/* $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>
*
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;