ask-password: prevent buffer overrow when reading from keyring
authorThadeu Lima de Souza Cascardo <cascardo@canonical.com>
Mon, 13 May 2019 19:58:01 +0000 (16:58 -0300)
committerThe Plumber <50238977+systemd-rhel-bot@users.noreply.github.com>
Mon, 21 Oct 2019 09:21:37 +0000 (11:21 +0200)
commitc6c8e0d097d6ba12471c6112c3fd339ea40329d5
treea6f387ad3efd7a317ef5c1c68dd8e495bd8a3b24
parent6240d78097c6f828aa2ca3b50ac322b41dc41fd1
ask-password: prevent buffer overrow 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)

Resolves: #1752050
src/shared/ask-password-api.c