Source-Changes-HG archive

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

[src/trunk]: src/lib/librefuse Zero-clear the fuse_context in fuse_destroy(3)



details:   https://anonhg.NetBSD.org/src/rev/5e73ef704388
branches:  trunk
changeset: 359771:5e73ef704388
user:      pho <pho%NetBSD.org@localhost>
date:      Sat Jan 22 08:07:02 2022 +0000

description:
Zero-clear the fuse_context in fuse_destroy(3)

diffstat:

 lib/librefuse/refuse.c |  18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)

diffs (46 lines):

diff -r 3c28277db470 -r 5e73ef704388 lib/librefuse/refuse.c
--- a/lib/librefuse/refuse.c    Sat Jan 22 08:06:21 2022 +0000
+++ b/lib/librefuse/refuse.c    Sat Jan 22 08:07:02 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: refuse.c,v 1.112 2022/01/22 08:05:35 pho Exp $ */
+/*     $NetBSD: refuse.c,v 1.113 2022/01/22 08:07:02 pho Exp $ */
 
 /*
  * Copyright © 2007 Alistair Crooks.  All rights reserved.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #if !defined(lint)
-__RCSID("$NetBSD: refuse.c,v 1.112 2022/01/22 08:05:35 pho Exp $");
+__RCSID("$NetBSD: refuse.c,v 1.113 2022/01/22 08:07:02 pho Exp $");
 #endif /* !lint */
 
 #include <sys/types.h>
@@ -207,6 +207,19 @@
 #endif
 }
 
+/* struct fuse_context is potentially reused among different
+ * invocations of fuse_new() / fuse_destroy() pair. Clear its content
+ * on fuse_destroy() so that no dangling pointers remain in the
+ * context. */
+static void
+clear_context(void)
+{
+       struct fuse_context     *ctx;
+
+       ctx = fuse_get_context();
+       memset(ctx, 0, sizeof(*ctx));
+}
+
 static void
 delete_context_key(void)
 {   
@@ -1384,6 +1397,7 @@
         * threads exist
         */
 
+       clear_context();
        delete_context_key();
        /* XXXXXX: missing stuff */
        free(fuse);



Home | Main Index | Thread Index | Old Index