nats-io / nats-server

High-Performance server for NATS.io, the cloud and edge native messaging system.
https://nats.io
Apache License 2.0
16k stars 1.41k forks source link

[v2.11] Fix meta step down panic on empty object #5993

Closed wallyqs closed 1 month ago

wallyqs commented 1 month ago

Side effect from https://github.com/nats-io/nats-server/pull/5956 some clients/natscli send empty objects to trigger the meta leader step down.

Jarema commented 1 month ago

This (the isEmptyRequest) protects the API by a side effect. The actual fix would be to check if pointer is nil before using its fields, as you could still cause panic by sending a field with a typo - not empty, yet Placement would be nil, and cause panic again. At least without strict marshaling.

I will check the other APIs. This fix is fine as a hotfix, but I would prefer to follow up later if you agree with above @derekcollison .

derekcollison commented 1 month ago

@Jarema ok to merge this one and we will follow up with separate PR?