Source-Changes-HG archive

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

[src/trunk]: src/sys/rump/librump/rumpvfs Fix off-by-atleast-1 error.



details:   https://anonhg.NetBSD.org/src/rev/02cd0b651937
branches:  trunk
changeset: 754314:02cd0b651937
user:      pooka <pooka%NetBSD.org@localhost>
date:      Tue Apr 27 13:26:12 2010 +0000

description:
Fix off-by-atleast-1 error.

Note: etfs doesn't work if rumpfs is not mounted as root.  Given
that rumpfs_mount always return EOPNOTSUPP (except for mountroot),
this is not a pressible tragedy currently, but nevertheless
could/should be fixed in the future.

diffstat:

 sys/rump/librump/rumpvfs/rumpfs.c |  12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diffs (34 lines):

diff -r 56c5cfbaac4b -r 02cd0b651937 sys/rump/librump/rumpvfs/rumpfs.c
--- a/sys/rump/librump/rumpvfs/rumpfs.c Tue Apr 27 10:58:55 2010 +0000
+++ b/sys/rump/librump/rumpvfs/rumpfs.c Tue Apr 27 13:26:12 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rumpfs.c,v 1.41 2010/04/26 23:40:22 pooka Exp $        */
+/*     $NetBSD: rumpfs.c,v 1.42 2010/04/27 13:26:12 pooka Exp $        */
 
 /*
  * Copyright (c) 2009  Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.41 2010/04/26 23:40:22 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.42 2010/04/27 13:26:12 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -519,8 +519,14 @@
                mutex_exit(&etfs_lock);
 
                if (found) {
+                       char *offset;
+
+                       offset = strstr(cnp->cn_pnbuf, et->et_key);
+                       KASSERT(offset);
+
                        rn = et->et_rn;
-                       cnp->cn_consume += et->et_keylen - cnp->cn_namelen;
+                       cnp->cn_consume += et->et_keylen
+                           - (cnp->cn_nameptr - offset) - cnp->cn_namelen;
                        if (rn->rn_va.va_type != VDIR)
                                cnp->cn_flags &= ~REQUIREDIR;
                        goto getvnode;



Home | Main Index | Thread Index | Old Index