Commit 6ecbbf1
committed
libckteec: fix integer overflow in PKCS#11 serializer
Add overflow check in serialize() to prevent size_t wraparound when
computing new buffer length. A crafted ulValueLen could cause *blen + len
to wrap, leading to a small realloc followed by an out-of-bounds memcpy.
Also add a bounds check in serialize_ck_attribute() for the
CKA_ALLOWED_MECHANISMS path where n * sizeof(uint32_t) could overflow
the uint32_t pkcs11_size, resulting in an undersized malloc.
Fixes: 85a7ea7 ("libckteec: introduce helpers for serializing data")
Signed-off-by: Minghao Cheng <m@minhal.me>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>1 parent 32ae379 commit 6ecbbf1
2 files changed
Lines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
| 176 | + | |
| 177 | + | |
176 | 178 | | |
177 | 179 | | |
178 | 180 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
49 | 53 | | |
50 | 54 | | |
51 | 55 | | |
| |||
0 commit comments