From owner-freebsd-fs@FreeBSD.ORG Wed Dec 10 03:41:37 2014 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 26DDEE45; Wed, 10 Dec 2014 03:41:37 +0000 (UTC) Received: from esa-annu.net.uoguelph.ca (esa-annu.mail.uoguelph.ca [131.104.91.36]) by mx1.freebsd.org (Postfix) with ESMTP id D25FF619; Wed, 10 Dec 2014 03:41:36 +0000 (UTC) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqYEALa/h1SDaFve/2dsb2JhbABZhDSDAckzgUMBAQEBAX2ELARSNQINGQJfiEu/dpclAQEBAQYBAQEBAQEcgSaOKTSCdoFHBYlAnzSEDCGBdX4BAQE X-IronPort-AV: E=Sophos;i="5.07,549,1413259200"; d="scan'208";a="176844796" Received: from muskoka.cs.uoguelph.ca (HELO zcs3.mail.uoguelph.ca) ([131.104.91.222]) by esa-annu.net.uoguelph.ca with ESMTP; 09 Dec 2014 22:41:31 -0500 Received: from zcs3.mail.uoguelph.ca (localhost.localdomain [127.0.0.1]) by zcs3.mail.uoguelph.ca (Postfix) with ESMTP id 358F4B404B; Tue, 9 Dec 2014 22:41:30 -0500 (EST) Date: Tue, 9 Dec 2014 22:41:30 -0500 (EST) From: Rick Macklem To: FreeBSD Filesystems Message-ID: <156074187.8997064.1418182890206.JavaMail.root@uoguelph.ca> Subject: fuse dirent bug??? MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [172.17.91.202] X-Mailer: Zimbra 7.2.6_GA_2926 (ZimbraWebClient - FF3.0 (Win)/7.2.6_GA_2926) Cc: George Neville-Neil X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Dec 2014 03:41:37 -0000 Hi, While looking at the fuse code to change it to use a new "struct dirent", I spotted this line, which doesn't look correct. Line 358 of sys/fs/fuse/fuse_internal.c: ((char *)cookediov->base)[bytesavail] = '\0'; - I think this is intended to null terminate the name, since it comes right after the memcpy() of the file name. However, bytesavail is the value returned by GENERIC_DIRSIZ(), which means [bytesavail] after "cookediov->base" would be the first byte after the "struct dirent" (including the space for null termination and padding. If I'm correct, I think this line can be replaced by: de->d_name[fudge->namelen] = '\0'; which would be the byte after the name in the structure. Also, although I think the first argument to the memcpy() call just above this is correct, it is complex/convoluted. Wouldn't just writing "memcpy(de->d_name, ..." make it more readable? Anyone out there familiar with fuse able to look at/test this? Thanks, rick