Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
ed551131
Commit
ed551131
authored
Jul 25, 2016
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commands: fix panic when expected files field is nil
License: MIT Signed-off-by:
Jeromy
<
why@ipfs.io
>
parent
566c08e2
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
6 deletions
+19
-6
commands/http/parse.go
commands/http/parse.go
+7
-3
commands/request.go
commands/request.go
+2
-1
test/sharness/t0600-issues-and-regressions-online.sh
test/sharness/t0600-issues-and-regressions-online.sh
+10
-2
No files found.
commands/http/parse.go
View file @
ed551131
...
@@ -104,13 +104,17 @@ func Parse(r *http.Request, root *cmds.Command) (cmds.Request, error) {
...
@@ -104,13 +104,17 @@ func Parse(r *http.Request, root *cmds.Command) (cmds.Request, error) {
contentType
:=
r
.
Header
.
Get
(
contentTypeHeader
)
contentType
:=
r
.
Header
.
Get
(
contentTypeHeader
)
mediatype
,
_
,
_
:=
mime
.
ParseMediaType
(
contentType
)
mediatype
,
_
,
_
:=
mime
.
ParseMediaType
(
contentType
)
var
f
*
files
.
Multipart
File
var
f
files
.
File
if
mediatype
==
"multipart/form-data"
{
if
mediatype
==
"multipart/form-data"
{
f
=
&
files
.
MultipartFile
{
Mediatype
:
mediatype
}
reader
,
err
:=
r
.
MultipartReader
()
f
.
Reader
,
err
=
r
.
MultipartReader
()
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
f
=
&
files
.
MultipartFile
{
Mediatype
:
mediatype
,
Reader
:
reader
,
}
}
}
// if there is a required filearg, error if no files were provided
// if there is a required filearg, error if no files were provided
...
...
commands/request.go
View file @
ed551131
...
@@ -231,7 +231,8 @@ func (r *request) VarArgs(f func(string) error) error {
...
@@ -231,7 +231,8 @@ func (r *request) VarArgs(f func(string) error) error {
}
}
if
r
.
files
==
nil
{
if
r
.
files
==
nil
{
return
fmt
.
Errorf
(
"expected more arguments from stdin"
)
log
.
Warning
(
"expected more arguments from stdin"
)
return
nil
}
}
fi
,
err
:=
r
.
files
.
NextFile
()
fi
,
err
:=
r
.
files
.
NextFile
()
...
...
test/sharness/t0600-issues-and-regressions-online.sh
View file @
ed551131
...
@@ -10,15 +10,23 @@ test_launch_ipfs_daemon
...
@@ -10,15 +10,23 @@ test_launch_ipfs_daemon
# Tests go here
# Tests go here
test_expect_sucess
"commands command with flag flags works via HTTP API - #2301"
'
test_expect_suc
c
ess
"commands command with flag flags works via HTTP API - #2301"
'
curl "http://$API_ADDR/api/v0/commands?flags" | grep "verbose"
curl "http://$API_ADDR/api/v0/commands?flags" | grep "verbose"
'
'
test_expect_sucess
"ipfs refs local over HTTP API returns NDJOSN not flat - #2803"
'
test_expect_suc
c
ess
"ipfs refs local over HTTP API returns NDJOSN not flat - #2803"
'
echo "Hello World" | ipfs add &&
echo "Hello World" | ipfs add &&
curl "http://$API_ADDR/api/v0/refs/local" | grep "Ref" | grep "Err"
curl "http://$API_ADDR/api/v0/refs/local" | grep "Ref" | grep "Err"
'
'
test_expect_success
"args expecting stdin dont crash when not given"
'
curl "$API_ADDR/api/v0/bootstrap/add" > result
'
test_expect_success
"no panic traces on daemon"
'
test_expect_failure grep "nil pointer dereference" daemon_err
'
test_kill_ipfs_daemon
test_kill_ipfs_daemon
test_done
test_done
...
...
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