]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Use Use smb3posix marshalling in in smbd_do_qfilepathinfo()
authorVolker Lendecke <vl@samba.org>
Wed, 27 Sep 2023 08:51:37 +0000 (10:51 +0200)
committerJeremy Allison <jra@samba.org>
Wed, 4 Oct 2023 20:31:36 +0000 (20:31 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/smb2_trans2.c

index 2ab8119735a5ed5803b4994c0151a8464a015fa7..788045584d00486a61116eb102c06736bbd9e99b 100644 (file)
@@ -3653,8 +3653,14 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
                 */
                case SMB2_FILE_POSIX_INFORMATION_INTERNAL:
                {
-                       uint8_t *buf = NULL;
-                       ssize_t plen = 0;
+                       struct smb3_file_posix_information info = {};
+                       uint8_t buf[sizeof(info)];
+                       struct ndr_push ndr = {
+                               .data = buf,
+                               .alloc_size = sizeof(buf),
+                               .fixed_buf_size = true,
+                       };
+                       enum ndr_err_code ndr_err;
 
                        if (!(conn->sconn->using_smb2)) {
                                return NT_STATUS_INVALID_LEVEL;
@@ -3666,30 +3672,17 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
                                return NT_STATUS_INVALID_LEVEL;
                        }
 
-                       /* Determine the size of the posix info context */
-                       plen = store_smb2_posix_info(conn,
-                                                    &smb_fname->st,
-                                                    0,
-                                                    mode,
-                                                    NULL,
-                                                    0);
-                       if (plen == -1 || data_size < plen) {
-                               return NT_STATUS_INVALID_PARAMETER;
-                       }
-                       buf = talloc_zero_size(mem_ctx, plen);
-                       if (buf == NULL) {
-                               return NT_STATUS_NO_MEMORY;
+                       smb3_file_posix_information_init(
+                               conn, &smb_fname->st, 0, mode, &info);
+
+                       ndr_err = ndr_push_smb3_file_posix_information(
+                               &ndr, NDR_SCALARS|NDR_BUFFERS, &info);
+                       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+                               return NT_STATUS_INSUFFICIENT_RESOURCES;
                        }
 
-                       /* Store the context in buf */
-                       store_smb2_posix_info(conn,
-                                             &smb_fname->st,
-                                             0,
-                                             mode,
-                                             buf,
-                                             plen);
-                       memcpy(pdata, buf, plen);
-                       data_size = plen;
+                       memcpy(pdata, buf, ndr.offset);
+                       data_size = ndr.offset;
                        break;
                }