Skip to content

Commit

Permalink
Merge pull request #259 from eriksjolund/handle-error-from-node-set-c…
Browse files Browse the repository at this point in the history
…ontent

erofs, mkcomposefs: Handle error from lcfs_node_set_content()
  • Loading branch information
cgwalters committed Mar 19, 2024
2 parents 9bc76dd + 49288d5 commit 9c393a4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 5 additions & 1 deletion libcomposefs/lcfs-writer-erofs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1602,6 +1602,7 @@ static struct lcfs_node_s *lcfs_build_node_from_image(struct lcfs_image_data *da
size_t tail_size;
const uint8_t *tail_data;
const uint8_t *oob_data;
int ret;

cino = lcfs_image_get_erofs_inode(data, nid);
if (cino == NULL)
Expand Down Expand Up @@ -1742,7 +1743,10 @@ static struct lcfs_node_s *lcfs_build_node_from_image(struct lcfs_image_data *da
if (tailpacked)
memcpy(content + oob_size, tail_data, tail_size);

lcfs_node_set_content(node, content, file_size);
ret = lcfs_node_set_content(node, content, file_size);
if (ret < 0) {
return NULL;
}
}

if (xattr_icount > 0) {
Expand Down
9 changes: 7 additions & 2 deletions tools/mkcomposefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,8 @@ static char *tree_resolve_hardlinks(dump_info *info)

static char *tree_from_dump_line(dump_info *info, const char *line, size_t line_len)
{
int ret;

/* Split out all fixed fields */
field_info fields[FIELD_XATTRS_START];
for (int i = 0; i < FIELD_XATTRS_START; i++) {
Expand Down Expand Up @@ -501,8 +503,11 @@ static char *tree_from_dump_line(dump_info *info, const char *line, size_t line_
lcfs_node_set_rdev(node, rdev);
lcfs_node_set_mtime(node, &mtime);
lcfs_node_set_payload(node, payload);
if (content)
lcfs_node_set_content(node, (uint8_t *)content, size);
if (content) {
ret = lcfs_node_set_content(node, (uint8_t *)content, size);
if (ret < 0)
oom();
}

if (digest) {
uint8_t raw[LCFS_DIGEST_SIZE];
Expand Down

0 comments on commit 9c393a4

Please sign in to comment.