diff mbox series

BUG: regression checking IVT

Message ID 20240219180946.133253-1-stefano.babic@swupdate.org
State Accepted
Headers show
Series BUG: regression checking IVT | expand

Commit Message

Stefano Babic Feb. 19, 2024, 6:09 p.m. UTC
e48a866542 creates a regression bug. A valid IVT pointer is always
passed because it is generally a zeroed array of chars, so passing null
length string is a valid case and not an error, and in that case the IVT
from the file should be taken.

Signed-off-by: Stefano Babic <stefano.babic@swupdate.org>
---
 core/cpio_utils.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--
2.34.1
diff mbox series

Patch

diff --git a/core/cpio_utils.c b/core/cpio_utils.c
index e5de2a79..7948dc2d 100644
--- a/core/cpio_utils.c
+++ b/core/cpio_utils.c
@@ -514,8 +514,8 @@  static int __swupdate_copy(int fdin, unsigned char *inbuf, void *out, size_t nby

 	if (encrypted) {
 		aes_key = get_aes_key();
-		if (imgivt) {
-			if (!strlen(imgivt) || !is_hex_str(imgivt) || ascii_to_bin(ivtbuf, sizeof(ivtbuf), imgivt)) {
+		if (imgivt && strlen(imgivt)) {
+			if (!is_hex_str(imgivt) || ascii_to_bin(ivtbuf, sizeof(ivtbuf), imgivt)) {
 				ERROR("Invalid image ivt");
 				return -EINVAL;
 			}