redis / hiredis

Minimalistic C client for Redis >= 1.2
BSD 3-Clause "New" or "Revised" License
6.15k stars 1.8k forks source link

SSL callbacks are set even if the SSL initialization fails #1233

Closed MeirShpilraien closed 3 months ago

MeirShpilraien commented 8 months ago

Hey, I encounter an issue where the SSL connection callbacks are set regardless of the success or failure of the SSL initialization. This happened here: https://github.com/redis/hiredis/blob/869f3d0ef1513dd0258ad7190c9914df16dcc4a4/ssl.c#L367

While the SSL initialization might failed later on and the c->privctx are not populated. This can cause crashes if, for example, redisSSLAsyncWrite will be called later on.

I can submit a PR to set the callbacks only on successful initialization but wanted to consult first if it makes sense or maybe I am missing something.

Thanks.