Check for nil before using HostConfig to adjustCpuShares#14917
Check for nil before using HostConfig to adjustCpuShares#14917LK4D4 merged 1 commit intomoby:masterfrom
Conversation
|
@srust thanks! Can you add a failing test case for this change also? And put the HostConfig nil check inside AdjustCpuShares pls |
|
this is a bug where when the client calls an older api (specifically < 1.19) version w/o hostconfig it results in this nil pointer dereference, failing test case: ping @calavera I've added this to 1.8 (remove it if I've mistaken) |
|
Ah thanks @runcom for the test case! Was just working through the test suite to add this. I'll move the nil check. |
a3e9b0e to
5e875be
Compare
5e875be to
5ebd73a
Compare
e4dae9d to
0933fa4
Compare
|
@srust could you also squash your commits down to just one pls? |
|
@runcom I've commited your patch for the unit test (hope that's okay). thanks again. I've pushed both the fix and test case and rebased with master. Let me know anything else you need for this. Thanks! |
0933fa4 to
3c73b1a
Compare
|
Squashed to one commit. |
|
LGTM |
There was a problem hiding this comment.
TestContainersApiCreateNoHostConfig118
Fix moby#14915. Add unit test for moby#14915. Thanks @runcom for the test case: when the client calls 1.18 api version w/o hostconfig it results in a nil pointer dereference. Signed-off-by: Stephen Rust <[email protected]>
3c73b1a to
c358a4c
Compare
|
Renamed unit test from code review. |
|
LGTM |
1 similar comment
|
LGTM |
Check for nil before using HostConfig to adjustCpuShares
|
cherry picked into #15091 |
Hi,
This fixes #14915 for me.
The remote API in master does not work for a /container/create request that comes in with a missing HostConfig sub-object. Docker will dereference a nil pointer.
The 'adjustCpuShares' function expects a valid HostConfig object.
It appears that the commit for #13218 changed the behavior of the decoder, to no longer create a new HostConfig object if none was specified over the API. That change appears to have broken the create call. With this fix applied, the issue no longer occurs.
Thanks!
Signed-off-by: Stephen Rust [email protected]