From 624b9ccf99313dfb2ad2331207fd20b9cb544222 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sat, 28 Sep 2019 23:12:51 +0200 Subject: Fix xattr writer: handle the case that no attributes where added If begin/end was called without recording *any* attributes, simply set the resulting index to the 0xFFFFFFFF sentinel. Signed-off-by: David Oberhollenzer --- lib/sqfs/xattr_writer.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/sqfs') diff --git a/lib/sqfs/xattr_writer.c b/lib/sqfs/xattr_writer.c index 318c613..fd35ca3 100644 --- a/lib/sqfs/xattr_writer.c +++ b/lib/sqfs/xattr_writer.c @@ -235,6 +235,10 @@ int sqfs_xattr_writer_end(sqfs_xattr_writer_t *xwr, sqfs_u32 *out) int ret; count = xwr->num_pairs - xwr->kv_start; + if (count == 0) { + *out = 0xFFFFFFFF; + return 0; + } qsort(xwr->kv_pairs + xwr->kv_start, count, sizeof(xwr->kv_pairs[0]), compare_u64); -- cgit v1.2.3