diff mbox series

[v5,14/16] cpio_utils: handle -EAGAIN and set eof only on success

Message ID 20250904115704.58413-15-Michael.Glembotzki@iris-sensing.com
State Changes Requested
Delegated to: Stefano Babic
Headers show
Series Add support for asymmetric decryption | expand

Commit Message

Michael Glembotzki Sept. 4, 2025, 11:50 a.m. UTC
copyfile continues on -EAGAIN instead of failing
decrypt_step sets eof only if final returned 0

Signed-off-by: Michael Glembotzki <Michael.Glembotzki@iris-sensing.com>
---
 core/cpio_utils.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/core/cpio_utils.c b/core/cpio_utils.c
index aff7a4bb..6ef38c15 100644
--- a/core/cpio_utils.c
+++ b/core/cpio_utils.c
@@ -319,7 +319,9 @@  static int decrypt_step(void *state, void *buffer, size_t size)
 			 */
 			ret = swupdate_DECRYPT_final(s->dcrypt,
 				s->output, &s->outlen);
-			s->eof = true;
+			if (ret == 0) {
+				s->eof = true;
+			}
 		}
 		if (ret < 0) {
 			return ret;
@@ -728,6 +730,9 @@  int copyfile(struct swupdate_copy *args)
 
 	for (;;) {
 		ret = step(state, buffer, sizeof buffer);
+		if (ret == -EAGAIN) {
+			continue;
+		}
 		if (ret < 0) {
 			goto copyfile_exit;
 		}