aboutsummaryrefslogtreecommitdiff
path: root/lib/util/filename_sane.c
blob: f98aafcc5a64b206f5433e562b98e12b56cfe897 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/* SPDX-License-Identifier: LGPL-3.0-or-later */
/*
 * filename_sane.c
 *
 * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
 */
#include "config.h"
#include "util/util.h"

#include <string.h>

bool is_filename_sane(const char *name)
{
	if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0)
		return false;

	while (*name != '\0') {
		if (*name == '/')
			return false;
		++name;
	}

	return true;
}