summaryrefslogtreecommitdiff
path: root/lib/common/filename_sane.c
blob: 6b497c381d2f563cf2c79989475811ca442e8cb3 (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
25
26
/* SPDX-License-Identifier: GPL-3.0-or-later */
/*
 * filename_sane.c
 *
 * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
 */
#include "common.h"

bool is_filename_sane(const char *name)
{
	if (name[0] == '.') {
		if (name[1] == '\0')
			return false;

		if (name[1] == '.' && name[2] == '\0')
			return false;
	}

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

	return true;
}