Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
babeld
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
babeld
Commits
02b14e38
Commit
02b14e38
authored
Feb 08, 2020
by
Antonin Décimo
Committed by
Juliusz Chroboczek
May 30, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Helpful error messages in key configuration.
parent
d763f3e0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
6 deletions
+23
-6
configuration.c
configuration.c
+23
-6
No files found.
configuration.c
View file @
02b14e38
...
...
@@ -755,8 +755,10 @@ parse_key(int c, gnc_t gnc, void *closure, struct key **key_return)
struct
key
*
key
;
key
=
calloc
(
1
,
sizeof
(
struct
key
));
if
(
key
==
NULL
)
if
(
key
==
NULL
)
{
perror
(
"calloc(key)"
);
return
-
2
;
}
while
(
1
)
{
c
=
skip_whitespace
(
c
,
gnc
,
closure
);
if
(
c
<
0
||
c
==
'\n'
||
c
==
'#'
)
{
...
...
@@ -786,32 +788,43 @@ parse_key(int c, gnc_t gnc, void *closure, struct key **key_return)
}
else
if
(
strcmp
(
auth_type
,
"blake2s"
)
==
0
)
{
key
->
type
=
AUTH_TYPE_BLAKE2S
;
}
else
{
fprintf
(
stderr
,
"Key type '%s' isn't supported.
\n
"
,
auth_type
);
free
(
auth_type
);
goto
error
;
}
free
(
auth_type
);
}
else
if
(
strcmp
(
token
,
"value"
)
==
0
)
{
c
=
gethex
(
c
,
&
key
->
value
,
&
key
->
len
,
gnc
,
closure
);
if
(
c
<
-
1
||
key
->
value
==
NULL
)
if
(
c
<
-
1
||
key
->
value
==
NULL
)
{
fprintf
(
stderr
,
"Couldn't parse key value.
\n
"
);
goto
error
;
}
}
else
{
fprintf
(
stderr
,
"Unrecognized keyword '%s'.
\n
"
,
token
);
goto
error
;
}
free
(
token
);
token
=
NULL
;
}
if
(
key
->
id
==
NULL
)
if
(
key
->
id
==
NULL
)
{
fprintf
(
stderr
,
"No key id was given.
\n
"
);
goto
error
;
}
switch
(
key
->
type
)
{
case
AUTH_TYPE_SHA256
:
{
if
(
key
->
len
>
64
)
if
(
key
->
len
>
64
)
{
fprintf
(
stderr
,
"Key length is %d, expected at most %d.
\n
"
,
key
->
len
,
64
);
goto
error
;
}
if
(
key
->
len
<
64
)
{
unsigned
char
*
v
=
realloc
(
key
->
value
,
64
);
if
(
v
==
NULL
)
if
(
v
==
NULL
)
{
perror
(
"realloc(key->value)"
);
goto
error
;
}
memset
(
v
+
key
->
len
,
0
,
64
-
key
->
len
);
key
->
value
=
v
;
key
->
len
=
64
;
...
...
@@ -819,10 +832,14 @@ parse_key(int c, gnc_t gnc, void *closure, struct key **key_return)
break
;
}
case
AUTH_TYPE_BLAKE2S
:
if
(
key
->
len
!=
16
)
if
(
key
->
len
!=
16
)
{
fprintf
(
stderr
,
"Key length is %d, expected %d.
\n
"
,
key
->
len
,
16
);
goto
error
;
}
break
;
default:
fprintf
(
stderr
,
"Key type 'none' isn't supported.
\n
"
);
goto
error
;
}
...
...
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