deps/libgit2/src/libgit2/path.h

filter: Statementstmt 42.8% 3 / 7 Branchbran 25.0% 1 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 36.3% 4 / 11 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« deps/libgit2/src/libgit2/xdiff/xemit.c ↑ Summary deps/libgit2/src/libgit2/revparse.c »
1 /*
2 * Copyright (C) the libgit2 contributors. All rights reserved.
3 *
4 * This file is part of libgit2, distributed under the GNU GPL v2 with
5 * a Linking Exception. For full terms see the included COPYING file.
6 */
7 #ifndef INCLUDE_path_h__
8 #define INCLUDE_path_h__
9  
10 #include "common.h"
11  
12 #include "fs_path.h"
13 #include <git2/sys/path.h>
14  
15 #define GIT_PATH_REJECT_DOT_GIT (GIT_FS_PATH_REJECT_MAX << 1)
16 #define GIT_PATH_REJECT_DOT_GIT_LITERAL (GIT_FS_PATH_REJECT_MAX << 2)
17 #define GIT_PATH_REJECT_DOT_GIT_HFS (GIT_FS_PATH_REJECT_MAX << 3)
18 #define GIT_PATH_REJECT_DOT_GIT_NTFS (GIT_FS_PATH_REJECT_MAX << 4)
19  
20 /* Paths that should never be written into the working directory. */
21 #define GIT_PATH_REJECT_WORKDIR_DEFAULTS \
22 GIT_FS_PATH_REJECT_FILESYSTEM_DEFAULTS | GIT_PATH_REJECT_DOT_GIT
23  
24 /* Paths that should never be written to the index. */
25 #define GIT_PATH_REJECT_INDEX_DEFAULTS \
26 GIT_FS_PATH_REJECT_TRAVERSAL | GIT_PATH_REJECT_DOT_GIT
27  
28 extern bool git_path_str_is_valid(
29 git_repository *repo,
30 const git_str *path,
31 uint16_t file_mode,
32 unsigned int flags);
33  
34 GIT_INLINE(bool) git_path_is_valid(
35 git_repository *repo,
36 const char *path,
37 uint16_t file_mode,
38 unsigned int flags)
39 {
40 git_str str = GIT_STR_INIT_CONST(path, SIZE_MAX);
41 return git_path_str_is_valid(repo, &str, file_mode, flags);
42 }
43  
44 939 GIT_INLINE(int) git_path_validate_str_length(
45 git_repository *repo,
46 const git_str *path)
47 {
48 939 ▶ if (!git_path_str_is_valid(repo, path, 0, GIT_FS_PATH_REJECT_LONG_PATHS)) {
Branch: 1 branch
BranchTrueFalseTotal
if (!git_path_str_is_valid(repo, path, 0, GIT_FS_PATH_REJECT_LONG_PATHS)) { 0 939 939
49 0 ▶ if (path->size == SIZE_MAX)
Branch: 1 branch
BranchTrueFalseTotal
if (path->size == SIZE_MAX) 0 0 0
50 0 git_error_set(GIT_ERROR_FILESYSTEM, "path too long: '%s'", path->ptr);
51 else
52 0 git_error_set(GIT_ERROR_FILESYSTEM, "path too long: '%.*s'", (int)path->size, path->ptr);
53  
54 0 return -1;
55 }
56  
57 939 return 0;
58 }
59  
60 GIT_INLINE(int) git_path_validate_length(
61 git_repository *repo,
62 const char *path)
63 {
64 git_str str = GIT_STR_INIT_CONST(path, SIZE_MAX);
65 return git_path_validate_str_length(repo, &str);
66 }
67  
68 #endif
« deps/libgit2/src/libgit2/xdiff/xemit.c ↑ Summary deps/libgit2/src/libgit2/revparse.c »