Fix misaligned read of CK_ULONG via void pointer.#860
Fix misaligned read of CK_ULONG via void pointer.#860citypw wants to merge 1 commit intosofthsm:mainfrom
Conversation
The PKCS#11 spec defines pValue as CK_VOID_PTR, which carries no alignment guarantee. Casting directly to CK_ULONG_PTR and dereferencing invokes undefined behaviour when the pointer is not 8-byte aligned (UBSAN: load of misaligned address). Replace the direct cast with memcpy(), which is the correct way to read an unaligned value in C/C++. Signed-off-by: Shawn C <citypw@hardenedlinux.org>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughModified the attribute value extraction in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
The PKCS#11 spec defines pValue as CK_VOID_PTR, which carries no alignment guarantee. Casting directly to CK_ULONG_PTR and dereferencing invokes undefined behaviour when the pointer is not 8-byte aligned (UBSAN: load of misaligned address).
Replace the direct cast with memcpy(), which is the correct way to read an unaligned value in C/C++.
Summary by CodeRabbit