Go-ipfs: Piped `ipfs add --hash id` kills the daemon

Created on 5 Nov 2017  路  4Comments  路  Source: ipfs/go-ipfs

Version information:

go-ipfs version: 0.4.12-rc1-5146b34
Repo version: 6
System version: amd64/linux
Golang version: go1.9.1

Type:

Bug

Severity:

Medium (potential vector for denial of service attack)

Description:

Adding piped content with --hash id kills the daemon:

 cat anyfile | ipfs add --hash id

go-ipfs output before shutting down:

panic: runtime error: slice bounds out of range

goroutine 16238 [running]:
gx/ipfs/QmU9a9NV9RdPNwZQDYd5uKsm6N6LJLSvLbywDDYFbaaC6P/go-multihash.Sum(0xc421864110, 0x4, 0x4, 0x0, 0x20, 0x4, 0x4, 0x0, 0x0, 0x1356c80)
    /go/src/gx/ipfs/QmU9a9NV9RdPNwZQDYd5uKsm6N6LJLSvLbywDDYFbaaC6P/go-multihash/sum.go:105 +0xd88
gx/ipfs/QmNp85zy9RLrQ5oQD4hPyS39ezrrXpcaa7R4Y9kxdWQLLQ/go-cid.Prefix.Sum(0x1, 0x70, 0x0, 0xffffffffffffffff, 0xc421864110, 0x4, 0x4, 0xc422043aa8, 0xc420031f08, 0x1)
    /go/src/gx/ipfs/QmNp85zy9RLrQ5oQD4hPyS39ezrrXpcaa7R4Y9kxdWQLLQ/go-cid/cid.go:434 +0x69
github.com/ipfs/go-ipfs/merkledag.(*ProtoNode).EncodeProtobuf(0xc420287960, 0xc420287900, 0xc4202879d0, 0x0, 0x0, 0x1c5b800, 0x1330fc0)
    /go/src/github.com/ipfs/go-ipfs/merkledag/coding.go:94 +0x1ed
github.com/ipfs/go-ipfs/merkledag.(*ProtoNode).RawData(0xc420287960, 0xc422043b78, 0xcb8b02, 0xc4206a5a00)
    /go/src/github.com/ipfs/go-ipfs/merkledag/node.go:206 +0x30
github.com/ipfs/go-ipfs/merkledag.(*ProtoNode).Cid(0xc420287960, 0x0)
    /go/src/github.com/ipfs/go-ipfs/merkledag/node.go:306 +0x9f
github.com/ipfs/go-ipfs/merkledag.(*ProtoNode).String(0xc420287960, 0x2, 0x8)
    /go/src/github.com/ipfs/go-ipfs/merkledag/node.go:318 +0x2b
github.com/ipfs/go-ipfs/mfs.NewRoot(0x1c50520, 0xc421012940, 0x1c55960, 0xc4214d0a70, 0xc420287960, 0x0, 0x36, 0xc421564cc0, 0x31)
    /go/src/github.com/ipfs/go-ipfs/mfs/system.go:92 +0x253
github.com/ipfs/go-ipfs/core/coreunix.(*Adder).mfsRoot(0xc4201535e0, 0xc421564cc0, 0x31, 0x1)
    /go/src/github.com/ipfs/go-ipfs/core/coreunix/add.go:121 +0xe4
github.com/ipfs/go-ipfs/core/coreunix.(*Adder).addNode(0xc4201535e0, 0x1c57720, 0xc4214d0ba0, 0xc421564cc0, 0x31, 0xc4201c09c0, 0x1c55960)
    /go/src/github.com/ipfs/go-ipfs/core/coreunix/add.go:394 +0x7d
github.com/ipfs/go-ipfs/core/coreunix.(*Adder).addFile(0xc4201535e0, 0x1c545e0, 0xc421926820, 0x0, 0x0)
    /go/src/github.com/ipfs/go-ipfs/core/coreunix/add.go:493 +0x480
github.com/ipfs/go-ipfs/core/coreunix.(*Adder).AddFile(0xc4201535e0, 0x1c545e0, 0xc421926820, 0x0, 0x0)
    /go/src/github.com/ipfs/go-ipfs/core/coreunix/add.go:431 +0x83
github.com/ipfs/go-ipfs/core/commands.glob..func6.1(0x1c54580, 0xc4218791d0, 0xc4218791d0, 0xc421864090)
    /go/src/github.com/ipfs/go-ipfs/core/commands/add.go:282 +0x83
github.com/ipfs/go-ipfs/core/commands.glob..func6.2(0xc421d96a20, 0xc421764d20, 0x1c595c0, 0xc420d206c0, 0x1c58900, 0xc420286770)
    /go/src/github.com/ipfs/go-ipfs/core/commands/add.go:302 +0x7c
created by github.com/ipfs/go-ipfs/core/commands.glob..func6
    /go/src/github.com/ipfs/go-ipfs/core/commands/add.go:300 +0xcce

kinbug panic

All 4 comments

In irc you were wondering if this was a bug or not. This one definitely counts as a bug.

I believe this is already fixed in go-multihash (unreleased).

@kevina It should be.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

funkyfuture picture funkyfuture  路  3Comments

kallisti5 picture kallisti5  路  3Comments

magik6k picture magik6k  路  3Comments

Kubuxu picture Kubuxu  路  3Comments

lidel picture lidel  路  3Comments