From 5fa8068580a24ff3fc7a3a53700b53eafc70db12 Mon Sep 17 00:00:00 2001 From: Simon Danner Date: Wed, 4 Jan 2023 13:53:34 +0100 Subject: [PATCH] LibPDF: Fix calculation of encryption key Before this patch, the generation of the encryption key was not working correctly since the lifetime of the underlying data was too short, same inputs would give random encryption keys. Fixes #16668 --- Userland/Libraries/LibPDF/Encryption.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibPDF/Encryption.cpp b/Userland/Libraries/LibPDF/Encryption.cpp index cf85870b0d..ac26a7c8fd 100644 --- a/Userland/Libraries/LibPDF/Encryption.cpp +++ b/Userland/Libraries/LibPDF/Encryption.cpp @@ -256,9 +256,9 @@ ByteBuffer StandardSecurityHandler::compute_encryption_key(ByteBuffer password_s n_bytes.ensure_capacity(m_length); while (n_bytes.size() < m_length) { - auto out = md5.peek().bytes(); - for (size_t j = 0; j < out.size() && n_bytes.size() < m_length; j++) - n_bytes.append(out[j]); + auto out = md5.peek(); + for (size_t j = 0; j < out.data_length() && n_bytes.size() < m_length; j++) + n_bytes.append(out.data[j]); } VERIFY(n_bytes.size() == m_length);