Line data Source code
1 : /* 2 : * Unix SMB/CIFS implementation. 3 : * Utility functions for reparse points. 4 : * 5 : * Copyright (C) Jeremy Allison 2018 6 : * 7 : * This program is free software; you can redistribute it and/or modify 8 : * it under the terms of the GNU General Public License as published by 9 : * the Free Software Foundation; either version 3 of the License, or 10 : * (at your option) any later version. 11 : * 12 : * This program is distributed in the hope that it will be useful, 13 : * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 : * GNU General Public License for more details. 16 : * 17 : * You should have received a copy of the GNU General Public License 18 : * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 : */ 20 : 21 : #include "includes.h" 22 : #include "util_reparse.h" 23 : 24 4 : NTSTATUS fsctl_get_reparse_point(struct files_struct *fsp, 25 : TALLOC_CTX *mem_ctx, 26 : char **out_data, 27 : uint32_t max_out_len, 28 : uint32_t *out_len) 29 : { 30 4 : DBG_DEBUG("Called on %s\n", fsp_str_dbg(fsp)); 31 4 : return NT_STATUS_NOT_A_REPARSE_POINT; 32 : } 33 : 34 18 : static NTSTATUS check_reparse_data_buffer( 35 : const uint8_t *in_data, size_t in_len) 36 : { 37 0 : uint16_t reparse_data_length; 38 : 39 18 : if (in_len == 0) { 40 4 : DBG_DEBUG("in_len=0\n"); 41 4 : return NT_STATUS_INVALID_BUFFER_SIZE; 42 : } 43 14 : if (in_len < 8) { 44 0 : DBG_DEBUG("in_len=%zu\n", in_len); 45 0 : return NT_STATUS_IO_REPARSE_DATA_INVALID; 46 : } 47 : 48 14 : reparse_data_length = PULL_LE_U16(in_data, 4); 49 : 50 14 : if (reparse_data_length != (in_len - 8)) { 51 0 : DBG_DEBUG("in_len=%zu, reparse_data_length=%"PRIu16"\n", 52 : in_len, 53 : reparse_data_length); 54 0 : return NT_STATUS_IO_REPARSE_DATA_INVALID; 55 : } 56 : 57 14 : return NT_STATUS_OK; 58 : } 59 : 60 18 : NTSTATUS fsctl_set_reparse_point(struct files_struct *fsp, 61 : TALLOC_CTX *mem_ctx, 62 : const uint8_t *in_data, 63 : uint32_t in_len) 64 : { 65 0 : NTSTATUS status; 66 : 67 18 : DBG_DEBUG("Called on %s\n", fsp_str_dbg(fsp)); 68 : 69 18 : status = check_reparse_data_buffer(in_data, in_len); 70 18 : if (!NT_STATUS_IS_OK(status)) { 71 4 : return status; 72 : } 73 : 74 14 : return NT_STATUS_NOT_A_REPARSE_POINT; 75 : } 76 : 77 0 : NTSTATUS fsctl_del_reparse_point(struct files_struct *fsp, 78 : TALLOC_CTX *mem_ctx, 79 : const uint8_t *in_data, 80 : uint32_t in_len) 81 : { 82 0 : DBG_DEBUG("Called on %s\n", fsp_str_dbg(fsp)); 83 0 : return NT_STATUS_NOT_A_REPARSE_POINT; 84 : }