]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs_streams_xattr: Add some overflow protection to pread and pwrite
authorVolker Lendecke <vl@samba.org>
Tue, 29 Jul 2025 12:49:33 +0000 (14:49 +0200)
committerVolker Lendecke <vl@samba.org>
Tue, 2 Sep 2025 08:08:29 +0000 (08:08 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
source3/modules/vfs_streams_xattr.c

index da20997a6a521dc4826f11555b2d5fbfa87cbd52..93044924b347b23f1ab270177fbe480613faab18 100644 (file)
@@ -1010,6 +1010,11 @@ static ssize_t streams_xattr_pwrite(vfs_handle_struct *handle,
                return SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
        }
 
+       if ((offset < 0) || ((offset + n) < n)) {
+               errno = EOVERFLOW;
+               return -1;
+       }
+
        if (!streams_xattr_recheck(sio)) {
                return -1;
        }
@@ -1092,6 +1097,11 @@ static ssize_t streams_xattr_pread(vfs_handle_struct *handle,
                return SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
        }
 
+       if ((offset < 0) || ((offset + n) < n)) {
+               errno = EOVERFLOW;
+               return -1;
+       }
+
        if (!streams_xattr_recheck(sio)) {
                return -1;
        }