-
Notifications
You must be signed in to change notification settings - Fork 711
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
Potential use of an uninitialized pointer "registered_mt" #2976
Comments
This was introduced as part of #2516. I think there were some memory issues before as it was storing several copies of the mechanism in some internal structures, making it impossible to free afterward. Certainly we should not use uninitialized values and if the memory management can be somehow simplified, I am all for it. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problem Description
When creating RSA mechanisms, I found a potential use of an uninitialized pointer (
registered_mt
).src/pkcs11/framework-pkcs15.c function register_mechanisms():
We rely on the function
sc_pkcs11_register_mechanism()
to always set the pointerregistered_mt
. However, thesc_pkcs11_register_mechanism()
function returns CKR_OK even in cases where the mechanism was not copied and the next initialization of the pointerregistered_mt
does not occur.part of
sc_pkcs11_register_mechanism()
Fortunately, when this code is actually executed,
registered_mt
initialization will always occur.If the pointer
registered_mt
is set (by callingsc_pkcs11_register_mechanism()
), it points to a copy of the information pointed to by the pointermt
. I suggest changing this part of the initialization and not usingregistered_mt
at all.It is enough if after calling
sc_pkcs11_register_mechanism()
we do not callsc_pkcs11_free_mechanism(&mt);
and instead ofregistered_mt
we usemt
to initialize SHA* using the functionsc_pkcs11_register_sign_and_hash_mechanism()
.Suggested code:
Will someone look at it and check if I missed something?
Similar code is in the initialization of RSA_*_PSS and EC mechanisms...
Thanks.
The text was updated successfully, but these errors were encountered: