From: Shwetha K Acharya Date: Tue, 28 Oct 2025 06:06:04 +0000 (+0530) Subject: vfs_streams_xattr: Fix CID 1667323 Resource Leak X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8d8a63e3f2ad467c692ac63ece6feb3bdfe0d8ab;p=thirdparty%2Fsamba.git vfs_streams_xattr: Fix CID 1667323 Resource Leak val was not freed on early return paths; addressed it using done block. Signed-off-by: Shwetha K Acharya Reviewed-by: Volker Lendecke Reviewed-by: Anoop C S --- diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c index 740d23a1952..9eb2d0068b5 100644 --- a/source3/modules/vfs_streams_xattr.c +++ b/source3/modules/vfs_streams_xattr.c @@ -1653,7 +1653,8 @@ static ssize_t streams_xattr_pread(vfs_handle_struct *handle, if (length < 1) { errno = EINVAL; - return -1; + ret = -1; + goto done; } length -= 1; @@ -1663,14 +1664,17 @@ static ssize_t streams_xattr_pread(vfs_handle_struct *handle, /* Attempt to read past EOF. */ if (length <= (size_t)offset) { /* offset>=0, see above */ - return 0; + ret = 0; + goto done; } overlap = (offset + n) > length ? (length - offset) : n; memcpy(data, val + offset, overlap); + ret = overlap; +done: TALLOC_FREE(val); - return overlap; + return ret; } struct streams_xattr_pread_state {