Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/fs/tmpfs Store symlinks without a NUL terminator so that...



details:   https://anonhg.NetBSD.org/src/rev/93cabc318b72
branches:  trunk
changeset: 802278:93cabc318b72
user:      gson <gson%NetBSD.org@localhost>
date:      Mon Sep 08 14:49:46 2014 +0000

description:
Store symlinks without a NUL terminator so that lstat(2) returns the
correct length.  Fixes the tmpfs part of PR kern/48864.

diffstat:

 sys/fs/tmpfs/tmpfs_subr.c  |  5 ++---
 sys/fs/tmpfs/tmpfs_vnops.c |  6 +++---
 2 files changed, 5 insertions(+), 6 deletions(-)

diffs (53 lines):

diff -r 92eec5759e71 -r 93cabc318b72 sys/fs/tmpfs/tmpfs_subr.c
--- a/sys/fs/tmpfs/tmpfs_subr.c Mon Sep 08 14:26:16 2014 +0000
+++ b/sys/fs/tmpfs/tmpfs_subr.c Mon Sep 08 14:49:46 2014 +0000
@@ -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 @@
                }
 
                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);
diff -r 92eec5759e71 -r 93cabc318b72 sys/fs/tmpfs/tmpfs_vnops.c
--- a/sys/fs/tmpfs/tmpfs_vnops.c        Mon Sep 08 14:26:16 2014 +0000
+++ b/sys/fs/tmpfs/tmpfs_vnops.c        Mon Sep 08 14:49:46 2014 +0000
@@ -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 @@
        /* 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;
        }



Home | Main Index | Thread Index | Old Index