Thu Dec 3 12:54:30 2009 UTC ()
Make sure node lengths match in addition to strncmp().
(I thought i fixed this already once?)


(pooka)
diff -r1.35 -r1.36 src/sys/rump/librump/rumpvfs/rumpfs.c

cvs diff -r1.35 -r1.36 src/sys/rump/librump/rumpvfs/rumpfs.c (expand / switch to unified diff)

--- src/sys/rump/librump/rumpvfs/rumpfs.c 2009/12/03 12:35:35 1.35
+++ src/sys/rump/librump/rumpvfs/rumpfs.c 2009/12/03 12:54:30 1.36
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: rumpfs.c,v 1.35 2009/12/03 12:35:35 pooka Exp $ */ 1/* $NetBSD: rumpfs.c,v 1.36 2009/12/03 12:54:30 pooka Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2009 Antti Kantee. All Rights Reserved. 4 * Copyright (c) 2009 Antti Kantee. All Rights Reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 14 *
@@ -16,27 +16,27 @@ @@ -16,27 +16,27 @@
16 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE. 25 * SUCH DAMAGE.
26 */ 26 */
27 27
28#include <sys/cdefs.h> 28#include <sys/cdefs.h>
29__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.35 2009/12/03 12:35:35 pooka Exp $"); 29__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.36 2009/12/03 12:54:30 pooka Exp $");
30 30
31#include <sys/param.h> 31#include <sys/param.h>
32#include <sys/atomic.h> 32#include <sys/atomic.h>
33#include <sys/dirent.h> 33#include <sys/dirent.h>
34#include <sys/errno.h> 34#include <sys/errno.h>
35#include <sys/filedesc.h> 35#include <sys/filedesc.h>
36#include <sys/fcntl.h> 36#include <sys/fcntl.h>
37#include <sys/kauth.h> 37#include <sys/kauth.h>
38#include <sys/malloc.h> 38#include <sys/malloc.h>
39#include <sys/module.h> 39#include <sys/module.h>
40#include <sys/mount.h> 40#include <sys/mount.h>
41#include <sys/namei.h> 41#include <sys/namei.h>
42#include <sys/lock.h> 42#include <sys/lock.h>
@@ -448,28 +448,29 @@ rump_vop_lookup(void *v) @@ -448,28 +448,29 @@ rump_vop_lookup(void *v)
448 mutex_enter(&etfs_lock); 448 mutex_enter(&etfs_lock);
449 if (etfs_find(cnp->cn_pnbuf, &rn)) { 449 if (etfs_find(cnp->cn_pnbuf, &rn)) {
450 mutex_exit(&etfs_lock); 450 mutex_exit(&etfs_lock);
451 cnp->cn_consume = strlen(cnp->cn_nameptr 451 cnp->cn_consume = strlen(cnp->cn_nameptr
452 + cnp->cn_namelen); 452 + cnp->cn_namelen);
453 cnp->cn_flags &= ~REQUIREDIR; 453 cnp->cn_flags &= ~REQUIREDIR;
454 goto getvnode; 454 goto getvnode;
455 } 455 }
456 mutex_exit(&etfs_lock); 456 mutex_exit(&etfs_lock);
457 } 457 }
458 458
459 if (!rd) { 459 if (!rd) {
460 LIST_FOREACH(rd, &rnd->rn_dir, rd_entries) { 460 LIST_FOREACH(rd, &rnd->rn_dir, rd_entries) {
461 if (strncmp(rd->rd_name, cnp->cn_nameptr, 461 if (strlen(rd->rd_name) == cnp->cn_namelen &&
462 cnp->cn_namelen) == 0) 462 strncmp(rd->rd_name, cnp->cn_nameptr,
 463 cnp->cn_namelen) == 0)
463 break; 464 break;
464 } 465 }
465 } 466 }
466 467
467 if (!rd && ((cnp->cn_flags & ISLASTCN) == 0||cnp->cn_nameiop != CREATE)) 468 if (!rd && ((cnp->cn_flags & ISLASTCN) == 0||cnp->cn_nameiop != CREATE))
468 return ENOENT; 469 return ENOENT;
469 470
470 if (!rd && (cnp->cn_flags & ISLASTCN) && cnp->cn_nameiop == CREATE) { 471 if (!rd && (cnp->cn_flags & ISLASTCN) && cnp->cn_nameiop == CREATE) {
471 cnp->cn_flags |= SAVENAME; 472 cnp->cn_flags |= SAVENAME;
472 return EJUSTRETURN; 473 return EJUSTRETURN;
473 } 474 }
474 rn = rd->rd_node; 475 rn = rd->rd_node;
475 rd = NULL; 476 rd = NULL;