Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
2c8c00c6
Commit
2c8c00c6
authored
Apr 21, 2015
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
config: validate config keys
parent
23fb4004
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
13 deletions
+41
-13
src/config_file.c
+41
-13
No files found.
src/config_file.c
View file @
2c8c00c6
...
@@ -1723,9 +1723,47 @@ static int parse_multiline_variable(struct reader *reader, git_buf *value, int i
...
@@ -1723,9 +1723,47 @@ static int parse_multiline_variable(struct reader *reader, git_buf *value, int i
return
0
;
return
0
;
}
}
GIT_INLINE
(
bool
)
is_namechar
(
char
c
)
{
return
isalnum
(
c
)
||
c
==
'-'
;
}
static
int
parse_name
(
char
**
name
,
const
char
**
value
,
struct
reader
*
reader
,
const
char
*
line
)
{
const
char
*
name_end
=
line
,
*
value_start
;
*
name
=
NULL
;
*
value
=
NULL
;
while
(
*
name_end
&&
is_namechar
(
*
name_end
))
name_end
++
;
if
(
line
==
name_end
)
{
set_parse_error
(
reader
,
0
,
"Invalid configuration key"
);
return
-
1
;
}
value_start
=
name_end
;
while
(
*
value_start
&&
git__isspace
(
*
value_start
))
value_start
++
;
if
(
*
value_start
==
'='
)
{
*
value
=
value_start
+
1
;
}
else
if
(
*
value_start
)
{
set_parse_error
(
reader
,
0
,
"Invalid configuration key"
);
return
-
1
;
}
if
((
*
name
=
git__strndup
(
line
,
name_end
-
line
))
==
NULL
)
return
-
1
;
return
0
;
}
static
int
parse_variable
(
struct
reader
*
reader
,
char
**
var_name
,
char
**
var_value
)
static
int
parse_variable
(
struct
reader
*
reader
,
char
**
var_name
,
char
**
var_value
)
{
{
const
char
*
var_end
=
NULL
;
const
char
*
value_start
=
NULL
;
const
char
*
value_start
=
NULL
;
char
*
line
;
char
*
line
;
int
quote_count
;
int
quote_count
;
...
@@ -1737,18 +1775,8 @@ static int parse_variable(struct reader *reader, char **var_name, char **var_val
...
@@ -1737,18 +1775,8 @@ static int parse_variable(struct reader *reader, char **var_name, char **var_val
quote_count
=
strip_comments
(
line
,
0
);
quote_count
=
strip_comments
(
line
,
0
);
var_end
=
strchr
(
line
,
'='
);
if
(
parse_name
(
var_name
,
&
value_start
,
reader
,
line
)
<
0
)
return
-
1
;
if
(
var_end
==
NULL
)
var_end
=
strchr
(
line
,
'\0'
);
else
value_start
=
var_end
+
1
;
do
var_end
--
;
while
(
var_end
>
line
&&
git__isspace
(
*
var_end
));
*
var_name
=
git__strndup
(
line
,
var_end
-
line
+
1
);
GITERR_CHECK_ALLOC
(
*
var_name
);
/* If there is no value, boolean true is assumed */
/* If there is no value, boolean true is assumed */
*
var_value
=
NULL
;
*
var_value
=
NULL
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment