From 38582b4fe4b96347e6f3090f30d15a8ed21f9e83 Mon Sep 17 00:00:00 2001 From: manu Date: Fri, 29 Aug 2014 04:58:40 +0000 Subject: [PATCH] We used to remove the trailing zeros in FUSE readlink replies, but it seems it does not always happen. Just remove them if present. --- lib/libperfuse/ops.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/libperfuse/ops.c b/lib/libperfuse/ops.c index b66557c358e3..fc05d9886b49 100644 --- a/lib/libperfuse/ops.c +++ b/lib/libperfuse/ops.c @@ -1,4 +1,4 @@ -/* $NetBSD: ops.c,v 1.69 2014/08/19 15:29:14 manu Exp $ */ +/* $NetBSD: ops.c,v 1.70 2014/08/29 04:58:40 manu Exp $ */ /*- * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved. @@ -2633,12 +2633,16 @@ perfuse_node_readlink(struct puffs_usermount *pu, puffs_cookie_t opc, if (len == 0) DERRX(EX_PROTOCOL, "path len = %zd too short", len); + (void)memcpy(linkname, _GET_OUTPAYLOAD(ps, pm, char *), len); + /* * FUSE filesystems return a NUL terminated string, we - * do not want to trailing \0 + * do not want the trailing \0 */ - *linklen = len - 1; - (void)memcpy(linkname, _GET_OUTPAYLOAD(ps, pm, char *), len); + while (len > 0 && linkname[len - 1] == '\0') + len--; + + *linklen = len; ps->ps_destroy_msg(pm); error = 0;