Skip to content

Commit 181dd00

Browse files
Merge pull request #4053 from Quantomicus/bugfix
Fixes #4003
2 parents 2f260ca + 48dcd67 commit 181dd00

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

core/coreunix/add.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,11 @@ func (adder *Adder) Finalize() (node.Node, error) {
223223
if err != nil {
224224
return nil, err
225225
}
226+
227+
if len(children) == 0 {
228+
return nil, fmt.Errorf("expected at least one child dir, got none")
229+
}
230+
226231
name = children[0]
227232

228233
mr, err := adder.mfsRoot()

test/sharness/t0600-issues-and-regressions-online.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ test_expect_success "pin add api looks right - #3753" '
4646
test_cmp pinrm_out pinrm_exp
4747
'
4848

49+
test_expect_success "no daemon crash on improper file argument - #4003" '
50+
FNC=$(echo $API_ADDR | awk -F: '\''{ printf "%s %s", $1, $2 }'\'') &&
51+
echo -n "POST /api/v0/add?pin=true HTTP/1.1\r\nHost: $API_ADDR\r\nContent-Type: multipart/form-data; boundary=Pyw9xQLtiLPE6XcI\r\nContent-Length: 22\r\n\r\n\r\n--Pyw9xQLtiLPE6XcI\r\n" | nc -v $FNC | grep "200 OK"
52+
'
53+
4954
test_kill_ipfs_daemon
5055

5156
test_expect_success "ipfs daemon --offline --mount fails - #2995" '

0 commit comments

Comments
 (0)