From 9b417be7260b7bc61cd7110b95ca9850e5c673aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Sj=C3=B6lund?= Date: Tue, 19 Mar 2024 21:03:38 +0100 Subject: [PATCH] writer: Set errno MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Set errno in the same way as it's done further down in the same file https://github.com/containers/composefs/blob/d5ffbeb6844cdbe029f9c10cfa98239e2d6b1570/libcomposefs/lcfs-writer.c#L1472 Set errno after munmap() to avoid overwriting the original errno. Signed-off-by: Erik Sjölund --- libcomposefs/lcfs-writer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libcomposefs/lcfs-writer.c b/libcomposefs/lcfs-writer.c index ea78385..3b64cf4 100644 --- a/libcomposefs/lcfs-writer.c +++ b/libcomposefs/lcfs-writer.c @@ -724,8 +724,8 @@ int lcfs_version_from_fd(int fd) } if (lcfs_u32_from_file(header->magic) != LCFS_EROFS_MAGIC || lcfs_u32_from_file(header->version) != LCFS_EROFS_VERSION) { - errno = EINVAL; munmap(header, header_size); + errno = EINVAL; return -1; } @@ -1155,6 +1155,7 @@ struct lcfs_node_s *lcfs_node_clone(struct lcfs_node_s *node) if (key == NULL || value == NULL) { free(key); free(value); + errno = ENOMEM; return NULL; } new->xattrs[i].key = key;