Commit 6f304d3
libckteec: fix CKA_ALLOWED_MECHANISMS size on 64-bit
On 64-bit systems, CKA_ALLOWED_MECHANISMS deserialization reports
the wire format size (count * sizeof(uint32_t)) instead of the
CK_ULONG-based size (count * sizeof(CK_ULONG)). This causes the
standard PKCS#11 size-query pattern to allocate a buffer that is
too small, leading to a heap buffer overflow when the mechanisms
are written as CK_ULONG values.
Fix the size reporting and buffer guard in deserialize_ck_attribute()
to use CK_ULONG-based sizes for CKA_ALLOWED_MECHANISMS, and fix the
buffer advancement in deserialize_ck_attributes() to match the wire
format size.
Signed-off-by: Minghao Cheng <m@minhal.me>
Reviewed-by: Jens Wiklander <jens.wiklander@oss.qualcomm.com>
Acked-by: Jerome Forissier <jerome.forissier@arm.com>1 parent ab96380 commit 6f304d3
1 file changed
Lines changed: 18 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
288 | 288 | | |
289 | 289 | | |
290 | 290 | | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
291 | 305 | | |
292 | 306 | | |
293 | 307 | | |
| |||
363 | 377 | | |
364 | 378 | | |
365 | 379 | | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
366 | 384 | | |
367 | 385 | | |
368 | 386 | | |
| |||
0 commit comments