Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
IRMA
Github mirrors
irmago
Commits
87bb01b3
Commit
87bb01b3
authored
Dec 19, 2018
by
Sietse Ringers
Browse files
Fix path handling that would break on relative paths
parent
e485a7a9
Changes
1
Hide whitespace changes
Inline
Side-by-side
irmaconfig.go
View file @
87bb01b3
...
...
@@ -273,8 +273,25 @@ func (conf *Configuration) ParseSchemeManagerFolder(dir string, manager *SchemeM
return
}
func
relativePath
(
absolute
string
,
relative
string
)
string
{
return
relative
[
len
(
absolute
)
+
1
:
]
// relativePath returns, given a outer path that contains the inner path,
// the relative path between outer an inner, which is such that
// outer/returnvalue refers to inner.
func
relativePath
(
outer
string
,
inner
string
)
(
string
,
error
)
{
// Take Abs() of both paths to ensure that we don't fail on e.g.
// outer = "./foo" and inner = "foo/bar"
outerAbs
,
err
:=
filepath
.
Abs
(
outer
)
if
err
!=
nil
{
return
""
,
err
}
innerAbs
,
err
:=
filepath
.
Abs
(
inner
)
if
err
!=
nil
{
return
""
,
err
}
if
!
strings
.
HasPrefix
(
innerAbs
,
outerAbs
)
{
return
""
,
errors
.
New
(
"inner path is not contained in outer path"
)
}
return
innerAbs
[
len
(
outerAbs
)
+
1
:
],
nil
}
// PublicKey returns the specified public key, or nil if not present in the Configuration.
...
...
@@ -408,7 +425,11 @@ func (conf *Configuration) parseKeysFolder(issuerid IssuerIdentifier) error {
if
err
!=
nil
{
return
err
}
bts
,
found
,
err
:=
conf
.
ReadAuthenticatedFile
(
manager
,
relativePath
(
conf
.
Path
,
file
))
relativepath
,
err
:=
relativePath
(
conf
.
Path
,
file
)
if
err
!=
nil
{
return
err
}
bts
,
found
,
err
:=
conf
.
ReadAuthenticatedFile
(
manager
,
relativepath
)
if
err
!=
nil
||
!
found
{
return
err
}
...
...
@@ -517,7 +538,11 @@ func (conf *Configuration) pathToDescription(manager *SchemeManager, path string
return
false
,
nil
}
bts
,
found
,
err
:=
conf
.
ReadAuthenticatedFile
(
manager
,
relativePath
(
conf
.
Path
,
path
))
relativepath
,
err
:=
relativePath
(
conf
.
Path
,
path
)
if
err
!=
nil
{
return
false
,
err
}
bts
,
found
,
err
:=
conf
.
ReadAuthenticatedFile
(
manager
,
relativepath
)
if
!
found
{
return
false
,
nil
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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