From: Luca Boccassi Date: Tue, 15 Apr 2025 21:44:24 +0000 (+0100) Subject: xattr: fix assert that breaks importctl (#37146) X-Git-Tag: v258-rc1~811 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=86cfbfae97cad2c22f7e9b3c2a8aea4171da5302;p=thirdparty%2Fsystemd.git xattr: fix assert that breaks importctl (#37146) getxattr_at_malloc() calls getxattr_pinned_internal() with size 0 to get the size of the xattr, and then asserts because n > 0 ``` Assertion '(size_t) n <= size' failed at src/basic/xattr-util.c:107, function getxattr_pinned_internal(). ``` Follow-up for b8df25dcfe674e37ceb3d54e00a31e1d33e96057 --- diff --git a/src/basic/xattr-util.c b/src/basic/xattr-util.c index deacc1025a6..9256bd4b1a4 100644 --- a/src/basic/xattr-util.c +++ b/src/basic/xattr-util.c @@ -104,7 +104,7 @@ static ssize_t getxattr_pinned_internal( if (n < 0) return -errno; - assert((size_t) n <= size); + assert(size == 0 || (size_t) n <= size); return n; } @@ -234,7 +234,7 @@ static int listxattr_pinned_internal( if (n < 0) return -errno; - assert((size_t) n <= size); + assert(size == 0 || (size_t) n <= size); if (n > INT_MAX) /* We couldn't return this as 'int' anymore */ return -E2BIG;