Module Name: src
Committed By: gson
Date: Mon Sep 8 14:49:47 UTC 2014
Modified Files:
src/sys/fs/tmpfs: tmpfs_subr.c tmpfs_vnops.c
Log Message:
Store symlinks without a NUL terminator so that lstat(2) returns the
correct length. Fixes the tmpfs part of PR kern/48864.
To generate a diff of this commit:
cvs rdiff -u -r1.96 -r1.97 src/sys/fs/tmpfs/tmpfs_subr.c
cvs rdiff -u -r1.120 -r1.121 src/sys/fs/tmpfs/tmpfs_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/tmpfs/tmpfs_subr.c
diff -u src/sys/fs/tmpfs/tmpfs_subr.c:1.96 src/sys/fs/tmpfs/tmpfs_subr.c:1.97
--- src/sys/fs/tmpfs/tmpfs_subr.c:1.96 Thu Jan 23 10:13:56 2014
+++ src/sys/fs/tmpfs/tmpfs_subr.c Mon Sep 8 14:49:46 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: tmpfs_subr.c,v 1.96 2014/01/23 10:13:56 hannken Exp $ */
+/* $NetBSD: tmpfs_subr.c,v 1.97 2014/09/08 14:49:46 gson Exp $ */
/*
* Copyright (c) 2005-2013 The NetBSD Foundation, Inc.
@@ -74,7 +74,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.96 2014/01/23 10:13:56 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.97 2014/09/08 14:49:46 gson Exp $");
#include <sys/param.h>
#include <sys/cprng.h>
@@ -185,7 +185,6 @@ tmpfs_alloc_node(tmpfs_mount_t *tmp, enu
}
KASSERT(nnode->tn_size < MAXPATHLEN);
- nnode->tn_size++; /* include the NUL terminator */
nnode->tn_spec.tn_lnk.tn_link =
tmpfs_strname_alloc(tmp, nnode->tn_size);
Index: src/sys/fs/tmpfs/tmpfs_vnops.c
diff -u src/sys/fs/tmpfs/tmpfs_vnops.c:1.120 src/sys/fs/tmpfs/tmpfs_vnops.c:1.121
--- src/sys/fs/tmpfs/tmpfs_vnops.c:1.120 Fri Jul 25 08:20:52 2014
+++ src/sys/fs/tmpfs/tmpfs_vnops.c Mon Sep 8 14:49:46 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: tmpfs_vnops.c,v 1.120 2014/07/25 08:20:52 dholland Exp $ */
+/* $NetBSD: tmpfs_vnops.c,v 1.121 2014/09/08 14:49:46 gson Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.120 2014/07/25 08:20:52 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.121 2014/09/08 14:49:46 gson Exp $");
#include <sys/param.h>
#include <sys/dirent.h>
@@ -1036,7 +1036,7 @@ tmpfs_readlink(void *v)
/* Note: readlink(2) returns the path without NUL terminator. */
if (node->tn_size > 0) {
error = uiomove(node->tn_spec.tn_lnk.tn_link,
- MIN(node->tn_size - 1, uio->uio_resid), uio);
+ MIN(node->tn_size, uio->uio_resid), uio);
} else {
error = 0;
}