diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2018-07-23 07:59:30 +0200 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2018-07-23 07:59:30 +0200 |
commit | 9aabd792ddba2f2baf31f14a55a21ab6b646d21d (patch) | |
tree | ee05aeaa4b22052e57e16922c453b019219240b3 /src/filesystem.c | |
parent | 486645a1b6ed3a12c938201e7729b4aeed5e1f93 (diff) | |
parent | b821e069cd21d212e64cbacc1d3dd1bd22419623 (diff) |
Merge branch 'master' into feature/jail_protocol
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'src/filesystem.c')
-rw-r--r-- | src/filesystem.c | 44 |
1 files changed, 39 insertions, 5 deletions
diff --git a/src/filesystem.c b/src/filesystem.c index 56cf05c..fa94987 100644 --- a/src/filesystem.c +++ b/src/filesystem.c @@ -1,3 +1,36 @@ +/* + * filesystem.c + * potd is licensed under the BSD license: + * + * Copyright (c) 2018 Toni Uhlig <matzeton@googlemail.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * - The names of its contributors may not be used to endorse or promote + * products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + #ifdef HAVE_CONFIG_H #include "config.h" #else @@ -16,6 +49,7 @@ #include <assert.h> #include "log.h" +#include "compat.h" #include "utils.h" #include "options.h" @@ -206,7 +240,7 @@ static MountData * get_last_mount(void) { FILE *fp = fopen("/proc/self/mountinfo", "r"); - char *ptr; + char *ptr, *saveptr = NULL; int cnt = 1; size_t len; @@ -232,11 +266,11 @@ get_last_mount(void) // mdata.dir: /home/netblue/.cache // mdata.fstype: tmpfs memset(&mdata, 0, sizeof(mdata)); - ptr = strtok(mbuf, " "); + ptr = potd_strtok(mbuf, " ", &saveptr); if (!ptr) goto errexit; - while ((ptr = strtok(NULL, " ")) != NULL) { + while ((ptr = potd_strtok(NULL, " ", &saveptr)) != NULL) { cnt++; if (cnt == 4) { mdata.fsname = ptr; @@ -246,11 +280,11 @@ get_last_mount(void) } } - ptr = strtok(NULL, "-"); + ptr = potd_strtok(NULL, "-", &saveptr); if (!ptr) goto errexit; - ptr = strtok(NULL, " "); + ptr = potd_strtok(NULL, " ", &saveptr); if (!ptr) goto errexit; mdata.fstype = ptr++; |