]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs_streams_xattr: Fix CID 1667323 Resource Leak
authorShwetha K Acharya <Shwetha.K.Acharya@ibm.com>
Tue, 28 Oct 2025 06:06:04 +0000 (11:36 +0530)
committerAnoop C S <anoopcs@samba.org>
Wed, 29 Oct 2025 13:40:29 +0000 (13:40 +0000)
val was not freed on early return paths; addressed it using
done block.

Signed-off-by: Shwetha K Acharya <Shwetha.K.Acharya@ibm.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
source3/modules/vfs_streams_xattr.c

index 740d23a19521b08100876ea721e3ab5f7353dbe9..9eb2d0068b566ca161b2cd6f5d80e047f2cf2361 100644 (file)
@@ -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 {