From 24f483f2c6f1b2e179e477c3affeb1f3a0a453ce Mon Sep 17 00:00:00 2001 From: Blair Bonnett Date: Wed, 5 Sep 2012 12:35:58 +1200 Subject: [PATCH] Also check CID when converting plugin_user to hub_user. Current lookup would return the wrong user if the intended user has left the hub and the SID has been re-used. If the CID matches then we assume the user is still there. --- src/core/plugincallback.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/core/plugincallback.c b/src/core/plugincallback.c index 573ec0f..e4e0667 100644 --- a/src/core/plugincallback.c +++ b/src/core/plugincallback.c @@ -58,7 +58,12 @@ static struct hub_user* convert_user_type(struct plugin_handle* plugin, struct p * the data in case the user quits before the plugin uses the list. Hence * we need to look it up by SID. */ struct hub_info* hub = plugin_get_hub(plugin); - return uman_get_user_by_sid(hub, user->sid); + struct hub_user* huser = uman_get_user_by_sid(hub, user->sid); + + /* Also need to check the CID matches to handle + * the case where the SID is re-used. */ + if(huser->id.cid == user->cid) return huser; + return NULL; } static int cbfunc_send_message(struct plugin_handle* plugin, struct plugin_user* user, const char* message)