diff mbox series

encrypted images: Prevent premature decryption end

Message ID 20200919212049.130074-1-bage@linutronix.de
State Accepted
Headers show
Series encrypted images: Prevent premature decryption end | expand

Commit Message

Bastian Germann Sept. 19, 2020, 9:20 p.m. UTC
From: Bastian Germann <bage@linutronix.de>

744def043e (encrypted images: fix one block sized image decryption), the
decryption for bigger block sizes was destroyed.  The condition must check
the output length, not the return of swupdate_DECRYPT_update().

Signed-off-by: Bastian Germann <bage@linutronix.de>
---
 core/cpio_utils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stefano Babic Sept. 20, 2020, 1:09 p.m. UTC | #1
Hi Bastian,

On 19.09.20 23:20, bage@linutronix.de wrote:
> From: Bastian Germann <bage@linutronix.de>
> 
> 744def043e (encrypted images: fix one block sized image decryption), the
> decryption for bigger block sizes was destroyed.  The condition must check
> the output length, not the return of swupdate_DECRYPT_update().
> 

Ouch...

> Signed-off-by: Bastian Germann <bage@linutronix.de>
> ---
>   core/cpio_utils.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/core/cpio_utils.c b/core/cpio_utils.c
> index 0ba85fd..3e268ad 100644
> --- a/core/cpio_utils.c
> +++ b/core/cpio_utils.c
> @@ -244,7 +244,7 @@ static int decrypt_step(void *state, void *buffer, size_t size)
>   			ret = swupdate_DECRYPT_update(s->dcrypt,
>   				s->output, &s->outlen, s->input, inlen);
>   		}
> -		if (inlen == 0 || ret == 0) {
> +		if (inlen == 0 || s->outlen == 0) {
>   			/*
>   			 * Finalise the decryption. Further plaintext bytes may
>   			 * be written at this stage.
> 

Applied to -master, thanks !

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/core/cpio_utils.c b/core/cpio_utils.c
index 0ba85fd..3e268ad 100644
--- a/core/cpio_utils.c
+++ b/core/cpio_utils.c
@@ -244,7 +244,7 @@  static int decrypt_step(void *state, void *buffer, size_t size)
 			ret = swupdate_DECRYPT_update(s->dcrypt,
 				s->output, &s->outlen, s->input, inlen);
 		}
-		if (inlen == 0 || ret == 0) {
+		if (inlen == 0 || s->outlen == 0) {
 			/*
 			 * Finalise the decryption. Further plaintext bytes may
 			 * be written at this stage.