Skip to content

Commit

Permalink
Merge pull request #159 from cgwalters/writer-ubsan-fix
Browse files Browse the repository at this point in the history
lib: Don't `qsort(NULL)`
  • Loading branch information
alexlarsson committed Jun 22, 2023
2 parents c0a7464 + dc1b304 commit e88fde3
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions libcomposefs/lcfs-writer.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,12 @@ int lcfs_compute_tree(struct lcfs_ctx_s *ctx, struct lcfs_node_s *root)
}

/* Canonical order */
qsort(node->children, node->children_size,
sizeof(node->children[0]), cmp_nodes);
qsort(node->xattrs, node->n_xattrs, sizeof(node->xattrs[0]),
cmp_xattr);
if (node->children)
qsort(node->children, node->children_size,
sizeof(node->children[0]), cmp_nodes);
if (node->xattrs)
qsort(node->xattrs, node->n_xattrs,
sizeof(node->xattrs[0]), cmp_xattr);

if (node->inode.st_mtim_sec < ctx->min_mtim_sec ||
(node->inode.st_mtim_sec == ctx->min_mtim_sec &&
Expand Down

0 comments on commit e88fde3

Please sign in to comment.