moby--moby/container
Kir Kolyshkin d6ea46ceda container.BaseFS: check for nil before deref
Commit 7a7357dae1 ("LCOW: Implemented support for docker cp + build")
changed `container.BaseFS` from being a string (that could be empty but
can't lead to nil pointer dereference) to containerfs.ContainerFS,
which could be be `nil` and so nil dereference is at least theoretically
possible, which leads to panic (i.e. engine crashes).

Such a panic can be avoided by carefully analysing the source code in all
the places that dereference a variable, to make the variable can't be nil.
Practically, this analisys are impossible as code is constantly
evolving.

Still, we need to avoid panics and crashes. A good way to do so is to
explicitly check that a variable is non-nil, returning an error
otherwise. Even in case such a check looks absolutely redundant,
further changes to the code might make it useful, and having an
extra check is not a big price to pay to avoid a panic.

This commit adds such checks for all the places where it is not obvious
that container.BaseFS is not nil (which in this case means we do not
call daemon.Mount() a few lines earlier).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2018-03-13 21:24:48 -07:00
..
stream Add canonical import comment 2018-02-05 16:51:57 -05:00
archive.go container.BaseFS: check for nil before deref 2018-03-13 21:24:48 -07:00
container.go container.BaseFS: check for nil before deref 2018-03-13 21:24:48 -07:00
container_linux.go Add canonical import comment 2018-02-05 16:51:57 -05:00
container_notlinux.go Add canonical import comment 2018-02-05 16:51:57 -05:00
container_unit_test.go Clean-up after container unit test 2018-02-28 01:15:15 +00:00
container_unix.go Merge configs/secrets in unix implementation 2018-02-16 11:25:14 -05:00
container_windows.go Merge configs/secrets in unix implementation 2018-02-16 11:25:14 -05:00
env.go Add canonical import comment 2018-02-05 16:51:57 -05:00
env_test.go Add canonical import comment 2018-02-05 16:51:57 -05:00
health.go Add canonical import comment 2018-02-05 16:51:57 -05:00
history.go Add canonical import comment 2018-02-05 16:51:57 -05:00
memory_store.go Add canonical import comment 2018-02-05 16:51:57 -05:00
memory_store_test.go Add canonical import comment 2018-02-05 16:51:57 -05:00
monitor.go Add canonical import comment 2018-02-05 16:51:57 -05:00
mounts_unix.go Add canonical import comment 2018-02-05 16:51:57 -05:00
mounts_windows.go Add canonical import comment 2018-02-05 16:51:57 -05:00
state.go Windows: Pass back system errors on container exit 2018-02-22 08:53:43 -08:00
state_test.go Add canonical import comment 2018-02-05 16:51:57 -05:00
store.go Add canonical import comment 2018-02-05 16:51:57 -05:00
view.go Add canonical import comment 2018-02-05 16:51:57 -05:00
view_test.go Add canonical import comment 2018-02-05 16:51:57 -05:00