-
Notifications
You must be signed in to change notification settings - Fork 51
Fix #559: Skip caching key with zero object handle #560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
It might happen that the object with zero object handle gets to cache_key which then result in unnecessary failure when caching the key. This skips the key caching if the object handle is 0.
This will probably need some sort of test so it's just a draft for now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nits, but otherwise LGTM!
@@ -388,6 +389,12 @@ static void cache_key(P11PROV_OBJ *obj) | |||
return; | |||
} | |||
|
|||
obj_handle = p11prov_obj_get_handle(obj); | |||
if (obj_handle == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please us CK_INVALID_HANDLE here.
@@ -388,6 +389,12 @@ static void cache_key(P11PROV_OBJ *obj) | |||
return; | |||
} | |||
|
|||
obj_handle = p11prov_obj_get_handle(obj); | |||
if (obj_handle == 0) { | |||
P11PROV_debug("Skip caching key with zero object handle"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
zero -> invalid
Do you have a way to add a test that exercises this code path ? |
I might be able to get it in some integration test with nginx. This is hopefully the last issue so once I get it all working, I would like to start looking into getting the fixes upstream which means adding the tests for the current patches where possible so will try then. |
Interestingly after this change, the skip is not even happening. I have done some experiments and just purely getting the handle before the |
This is a solution for #559 .
It might happen that the object with zero object handle gets to cache_key which then result in unnecessary failure when caching the key. This skips the key caching if the object handle is 0.
Interestingly after this the handshake became much quicker so it might have some impact on performance as well. I can't say it for sure if it impacts production as I use everything with debug build but it should save some session logins for sure.
Checklist
Reviewer's checklist: