*/
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;
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;
}