summaryrefslogtreecommitdiffstats
path: root/attr.c
diff options
context:
space:
mode:
authorEric Sesterhenn <eric.sesterhenn@x41-dsec.de>2024-10-14 23:04:09 +0200
committerTaylor Blau <me@ttaylorr.com>2024-10-17 00:14:11 +0200
commit72686d4e5e9a7236b9716368d86fae5bf1ae6156 (patch)
tree9b2db38be18ad967656502f6bdfc952409a49a33 /attr.c
parentfuzz: port fuzz-credential-from-url-gently from OSS-Fuzz (diff)
downloadgit-72686d4e5e9a7236b9716368d86fae5bf1ae6156.tar.xz
git-72686d4e5e9a7236b9716368d86fae5bf1ae6156.zip
fuzz: port fuzz-parse-attr-line from OSS-Fuzz
Git's fuzz tests are run continuously as part of OSS-Fuzz [1]. Several additional fuzz tests have been contributed directly to OSS-Fuzz; however, these tests are vulnerable to bitrot because they are not built during Git's CI runs, and thus breaking changes are much less likely to be noticed by Git contributors. Port one of these tests back to the Git project: fuzz-parse-attr-line This test was originally written by Eric Sesterhenn as part of a security audit of Git [2]. It was then contributed to the OSS-Fuzz repo in commit c58ac4492 (Git fuzzing: uncomment the existing and add new targets. (#11486), 2024-02-21) by Jaroslav Lobačevski. I (Josh Steadmon) have verified with both Eric and Jaroslav that they're OK with moving this test to the Git project. [1] https://github.com/google/oss-fuzz [2] https://ostif.org/wp-content/uploads/2023/01/X41-OSTIF-Gitlab-Git-Security-Audit-20230117-public.pdf Co-authored-by: Jaroslav Lobačevski <jarlob@gmail.com> Co-authored-by: Josh Steadmon <steadmon@google.com> Signed-off-by: Josh Steadmon <steadmon@google.com> Signed-off-by: Taylor Blau <me@ttaylorr.com>
Diffstat (limited to 'attr.c')
-rw-r--r--attr.c40
1 files changed, 2 insertions, 38 deletions
diff --git a/attr.c b/attr.c
index c605d2c170..192936c4bc 100644
--- a/attr.c
+++ b/attr.c
@@ -259,42 +259,6 @@ const struct git_attr *git_attr(const char *name)
return git_attr_internal(name, strlen(name));
}
-/* What does a matched pattern decide? */
-struct attr_state {
- const struct git_attr *attr;
- const char *setto;
-};
-
-struct pattern {
- const char *pattern;
- int patternlen;
- int nowildcardlen;
- unsigned flags; /* PATTERN_FLAG_* */
-};
-
-/*
- * One rule, as from a .gitattributes file.
- *
- * If is_macro is true, then u.attr is a pointer to the git_attr being
- * defined.
- *
- * If is_macro is false, then u.pat is the filename pattern to which the
- * rule applies.
- *
- * In either case, num_attr is the number of attributes affected by
- * this rule, and state is an array listing them. The attributes are
- * listed as they appear in the file (macros unexpanded).
- */
-struct match_attr {
- union {
- struct pattern pat;
- const struct git_attr *attr;
- } u;
- char is_macro;
- size_t num_attr;
- struct attr_state state[FLEX_ARRAY];
-};
-
static const char blank[] = " \t\r\n";
/* Flags usable in read_attr() and parse_attr_line() family of functions. */
@@ -353,8 +317,8 @@ static const char *parse_attr(const char *src, int lineno, const char *cp,
return ep + strspn(ep, blank);
}
-static struct match_attr *parse_attr_line(const char *line, const char *src,
- int lineno, unsigned flags)
+struct match_attr *parse_attr_line(const char *line, const char *src,
+ int lineno, unsigned flags)
{
size_t namelen, num_attr, i;
const char *cp, *name, *states;