Modules: handle NULL pointer in BlockClient#4366
Modules: handle NULL pointer in BlockClient#4366soloestoy wants to merge 2 commits intoredis:unstablefrom
Conversation
|
@soloestoy it is assumed that the developer will not set a NULL timeout function with a real timeout value. I don't think we should protect from it, especially not in that way. |
|
Yes, but I think it is necessary because we allow developers to set NULL timeout function, and we already check the Why don't we check |
|
Is it better to only allow timeout function be NULL when timeout is zero in the API |
|
@dvirsky another question, it seems that we allow developers call Do we allow developers do replication in |
|
Hello @soloestoy, @dvirsky, to set a NULL callback with non-zero timeout is indeed an API misuse, however what we could do to fix this instead is to just register a default timeout callback if NULL is passed. One just replying "-ERR blocked module command timed out, but timeout callback is NULL". This will be much more evident and does not need any extra check. About the second fix, it's odd that people could do actual work in the timeout callback, but there is also no easy way to prevent it, so I think that you fix makes sense here: at least it does not break replication in that case, so I'm merging 5021e3c. About the other fix, if you agree with the fix, you can write the default timeout handler inside module.c and set it in case it's NULL (even if the timeout it's 0, you never know if the internals could call the function in the future). Thanks for your help! |
|
No sorry can't merge just one, the two touch the same code. I'll wait for some update of the PR. Thanks. |
|
OK, I will update this PR later. |
5021e3c to
4574af2
Compare
|
PR updated, please check @antirez |
6640017 to
b66fbf9
Compare
|
|
Redis may crash if we pass a NULL
timeout_callbackto module APIRedisModule_BlockClient, because we doesn't check thetimeout_callbackwhen the client really reach the timeout.The
timeout_callbackcan only be executed when it is not NULL, and we should reply -1 to clientwhen
timeout_callbackis NULL to tell client that timeout occurs.