From: Volker Lendecke Date: Wed, 27 Sep 2023 08:51:37 +0000 (+0200) Subject: smbd: Use Use smb3posix marshalling in in smbd_do_qfilepathinfo() X-Git-Tag: tevent-0.16.0~240 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2d6c643ebddda0f5472fa83127a6a7a28ad37728;p=thirdparty%2Fsamba.git smbd: Use Use smb3posix marshalling in in smbd_do_qfilepathinfo() Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/source3/smbd/smb2_trans2.c b/source3/smbd/smb2_trans2.c index 2ab8119735a..788045584d0 100644 --- a/source3/smbd/smb2_trans2.c +++ b/source3/smbd/smb2_trans2.c @@ -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; }