optiopay / klar

Integration of Clair and Docker Registry
MIT License
506 stars 140 forks source link

Fixed: Try to drain response body only if response exists #158

Closed ericrpowers closed 4 years ago

ericrpowers commented 4 years ago

Description

While leveraging the klar repo, we noticed the following panic:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x40 pc=0xb868c9]

goroutine 3890993 [running]:
github.com/optiopay/klar/docker.(*Image).requestToken(0xc00551bec0, 0xc01d6fcfc0, 0x0, 0x0, 0x0, 0x0)
    /tmp/build/ae5c2d4a/go/pkg/mod/github.com/optiopay/klar@v2.4.0+incompatible/docker/docker.go:295 +0x6e9
github.com/optiopay/klar/docker.(*Image).Pull(0xc00551bec0, 0x0, 0x0)
    /tmp/build/ae5c2d4a/go/pkg/mod/github.com/optiopay/klar@v2.4.0+incompatible/docker/docker.go:222 +0x1e1
go.aporeto.io/claire/internal/scanner.(*clairScanner).cacheImage(0xc0003ac540, 0xc009ec3e60, 0xf, 0xc04f6d3e40, 0xc0154aaa90)

The response is not checked if it is nil prior to trying to drain it. This will avoid the panic. : )