Source-Changes-HG archive

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

[src/trunk]: src/lib/libpuffs Do not warn about relative path because of trai...



details:   https://anonhg.NetBSD.org/src/rev/4339199f74df
branches:  trunk
changeset: 805172:4339199f74df
user:      manu <manu%NetBSD.org@localhost>
date:      Mon Dec 22 08:16:21 2014 +0000

description:
Do not warn about relative path because of trailing slash

libpuffs calls realpath() to obtain an absolute path to use for mounting.
If the obtained path is different from the one given by the caller, a
warning is issued. This included the situation where the path passed by
the caller just have trailing slashes, a situation where we just want them
to be striped without a warning.

diffstat:

 lib/libpuffs/puffs.c |  10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diffs (37 lines):

diff -r 207fd26f6b0b -r 4339199f74df lib/libpuffs/puffs.c
--- a/lib/libpuffs/puffs.c      Mon Dec 22 07:02:22 2014 +0000
+++ b/lib/libpuffs/puffs.c      Mon Dec 22 08:16:21 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: puffs.c,v 1.118 2014/10/31 13:56:04 manu Exp $ */
+/*     $NetBSD: puffs.c,v 1.119 2014/12/22 08:16:21 manu Exp $ */
 
 /*
  * Copyright (c) 2005, 2006, 2007  Antti Kantee.  All Rights Reserved.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #if !defined(lint)
-__RCSID("$NetBSD: puffs.c,v 1.118 2014/10/31 13:56:04 manu Exp $");
+__RCSID("$NetBSD: puffs.c,v 1.119 2014/12/22 08:16:21 manu Exp $");
 #endif /* !lint */
 
 #include <sys/param.h>
@@ -574,13 +574,17 @@
                rv = 0;
        } else {
                char rp[MAXPATHLEN];
+               size_t rplen,dirlen;
 
                if (realpath(dir, rp) == NULL) {
                        rv = -1;
                        goto out;
                }
 
-               if (strcmp(dir, rp) != 0) {
+               rplen = strlen(rp);
+               dirlen = strlen(dir);
+               if (strncmp(dir, rp, rplen) != 0 ||
+                   strspn(dir + rplen, "/") != dirlen - rplen) {
                        warnx("puffs_mount: \"%s\" is a relative path.", dir);
                        warnx("puffs_mount: using \"%s\" instead.", rp);
                }



Home | Main Index | Thread Index | Old Index