mirror of
https://github.com/systemd/systemd.git
synced 2026-08-04 15:10:33 +00:00
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>
This commit is contained in:
committed by
Lennart Poettering
parent
deb2cfa4c6
commit
59c55e73ea
@@ -80,7 +80,7 @@ static int retrieve_key(key_serial_t serial, char ***ret) {
|
||||
if (n < m)
|
||||
break;
|
||||
|
||||
explicit_bzero_safe(p, n);
|
||||
explicit_bzero_safe(p, m);
|
||||
|
||||
if (m > LONG_MAX / 2) /* overflow check */
|
||||
return -ENOMEM;
|
||||
|
||||
Reference in New Issue
Block a user