]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs_fruit: prepare fruit_pread_meta() for reading on fake-fd
authorRalph Boehme <slow@samba.org>
Wed, 22 Aug 2018 13:22:08 +0000 (15:22 +0200)
committerKarolin Seeger <kseeger@samba.org>
Tue, 6 Nov 2018 08:10:25 +0000 (09:10 +0100)
If the read on the stream fails we may have hit a handle on a just
created stream (fio->created=true) with no data written yet.

If that's the case return an empty initialized FinderInfo blob.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit d7d92710711f6e555ed45c1dda528cd6a83e1bf5)

source3/modules/vfs_fruit.c

index 8ff82f6e4613060a819a6ff5aa148f089b9ee818..442ed1a9052cb1f87d15dfef7db7590b34316ad0 100644 (file)
@@ -4194,8 +4194,7 @@ static ssize_t fruit_pread_meta_stream(vfs_handle_struct *handle,
        int ret;
 
        nread = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
-
-       if (nread == n) {
+       if (nread == -1 || nread == n) {
                return nread;
        }
 
@@ -4294,6 +4293,25 @@ static ssize_t fruit_pread_meta(vfs_handle_struct *handle,
                return -1;
        }
 
+       if (nread == -1 && fio->created) {
+               AfpInfo *ai = NULL;
+               char afpinfo_buf[AFP_INFO_SIZE];
+
+               ai = afpinfo_new(talloc_tos());
+               if (ai == NULL) {
+                       return -1;
+               }
+
+               nread = afpinfo_pack(ai, afpinfo_buf);
+               TALLOC_FREE(ai);
+               if (nread != AFP_INFO_SIZE) {
+                       return -1;
+               }
+
+               memcpy(data, afpinfo_buf, to_return);
+               return to_return;
+       }
+
        return nread;
 }