Source-Changes-HG archive

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

[src/trunk]: src/lib/libperfuse FUSE filesystems' readlink returns a resolved...



details:   https://anonhg.NetBSD.org/src/rev/de316adefb28
branches:  trunk
changeset: 757986:de316adefb28
user:      manu <manu%NetBSD.org@localhost>
date:      Mon Oct 11 01:52:05 2010 +0000

description:
FUSE filesystems' readlink returns a resolved link with a NUL trailing
character, and PUFFS do not want it. This fixes this bug, that returned
stat the informations for x instead of reporting ENOENT:
mkdir x && ln x z && stat -x z/whatever/you/want

diffstat:

 lib/libperfuse/ops.c |  14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diffs (31 lines):

diff -r 1c7df9e8d580 -r de316adefb28 lib/libperfuse/ops.c
--- a/lib/libperfuse/ops.c      Mon Oct 11 01:12:25 2010 +0000
+++ b/lib/libperfuse/ops.c      Mon Oct 11 01:52:05 2010 +0000
@@ -1,4 +1,4 @@
-/*  $NetBSD: ops.c,v 1.21 2010/10/11 01:08:26 manu Exp $ */
+/*  $NetBSD: ops.c,v 1.22 2010/10/11 01:52:05 manu Exp $ */
 
 /*-
  *  Copyright (c) 2010 Emmanuel Dreyfus. All rights reserved.
@@ -2410,12 +2410,18 @@
                goto out;
 
        foh = GET_OUTHDR(ps, pm);
-       len = foh->len - sizeof(*foh) + 1;
+       len = foh->len - sizeof(*foh);
        if (len > *linklen)
                DERRX(EX_PROTOCOL, "path len = %zd too long", len);
+       if (len == 0)
+               DERRX(EX_PROTOCOL, "path len = %zd too short", len);
                
-       *linklen = len;
-       (void)strlcpy(linkname, _GET_OUTPAYLOAD(ps, pm, char *), len);
+       /*
+        * FUSE filesystems return a NUL terminated string, we 
+        * do not want to trailing \0
+        */
+       *linklen = len - 1;
+       (void)memcpy(linkname, _GET_OUTPAYLOAD(ps, pm, char *), len);
 out:
        ps->ps_destroy_msg(pm);
 



Home | Main Index | Thread Index | Old Index