ask-password: prevent buffer overflow when reading from keyring
authorMichael Biebl <biebl@debian.org>
Thu, 27 Jun 2019 13:02:40 +0000 (15:02 +0200)
committerAdrian Bunk <bunk@debian.org>
Thu, 30 Mar 2023 19:32:31 +0000 (20:32 +0100)
commit5c2e7a93cbf09110977be9c6fb66088739545e28
treed8a91c55e2601aafee4206085fa2ebfdfba187da
parentc33a91d50852eb56684c0403a19bd9d87e6f5ef5
ask-password: prevent buffer overflow when reading from keyring

When we read from keyring, a temporary buffer is allocated in order to
determine the size needed for the entire data. However, when zeroing that area,
we use the data size returned by the read instead of the lesser size allocate
for the buffer.

That will cause memory corruption that causes systemd-cryptsetup to crash
either when a single large password is used or when multiple passwords have
already been pushed to the keyring.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
(cherry picked from commit 59c55e73eaee345e1ee67c23eace8895ed499693)

Gbp-Pq: Name ask-password-prevent-buffer-overflow-when-reading-from-ke.patch
src/shared/ask-password-api.c