Changeset 919 for vendor/current/source3/librpc
- Timestamp:
- Jun 9, 2016, 2:17:22 PM (9 years ago)
- Location:
- vendor/current/source3/librpc/rpc
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/librpc/rpc/dcerpc.h
r917 r919 40 40 enum dcerpc_AuthType auth_type; 41 41 enum dcerpc_AuthLevel auth_level; 42 bool verified_bitmask1; 42 43 43 44 void *auth_ctx; 45 uint32_t auth_context_id; 44 46 45 47 /* Only the client code uses these 3 for now */ … … 71 73 const DATA_BLOB *credentials, 72 74 DATA_BLOB *blob); 73 NTSTATUS dcerpc_pull_dcerpc_auth(TALLOC_CTX *mem_ctx,74 const DATA_BLOB *blob,75 struct dcerpc_auth *r,76 bool bigendian);77 75 NTSTATUS dcerpc_guess_sizes(struct pipe_auth_data *auth, 78 76 size_t header_len, size_t data_left, … … 85 83 struct ncacn_packet *pkt, 86 84 DATA_BLOB *pkt_trailer, 87 size_t header_size, 88 DATA_BLOB *raw_pkt, 89 size_t *pad_len); 85 uint8_t header_size, 86 DATA_BLOB *raw_pkt); 90 87 91 88 /* The following definitions come from librpc/rpc/rpc_common.c */ -
vendor/current/source3/librpc/rpc/dcerpc_helpers.c
r860 r919 211 211 212 212 /** 213 * @brief Decodes a dcerpc_auth blob214 *215 * @param mem_ctx The memory context on which to allocate the packet216 * elements217 * @param blob The blob of data to decode218 * @param r An empty dcerpc_auth structure, must not be NULL219 *220 * @return a NTSTATUS error code221 */222 NTSTATUS dcerpc_pull_dcerpc_auth(TALLOC_CTX *mem_ctx,223 const DATA_BLOB *blob,224 struct dcerpc_auth *r,225 bool bigendian)226 {227 enum ndr_err_code ndr_err;228 struct ndr_pull *ndr;229 230 ndr = ndr_pull_init_blob(blob, mem_ctx);231 if (!ndr) {232 return NT_STATUS_NO_MEMORY;233 }234 if (bigendian) {235 ndr->flags |= LIBNDR_FLAG_BIGENDIAN;236 }237 238 ndr_err = ndr_pull_dcerpc_auth(ndr, NDR_SCALARS|NDR_BUFFERS, r);239 240 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {241 talloc_free(ndr);242 return ndr_map_error2ntstatus(ndr_err);243 }244 talloc_free(ndr);245 246 if (DEBUGLEVEL >= 10) {247 NDR_PRINT_DEBUG(dcerpc_auth, r);248 }249 250 return NT_STATUS_OK;251 }252 253 /**254 213 * @brief Calculate how much data we can in a packet, including calculating 255 214 * auth token and pad lengths. … … 783 742 auth->auth_level, 784 743 pad_len, 785 1 /* context id. */,744 auth->auth_context_id, 786 745 &auth_blob, 787 746 &auth_info); … … 845 804 * @param auth The auth data for the connection 846 805 * @param pkt The actual ncacn_packet 847 * @param pkt_trailer The stub_and_verifier part of the packet 806 * @param pkt_trailer [in][out] The stub_and_verifier part of the packet, 807 * the auth_trailer and padding will be removed. 848 808 * @param header_size The header size 849 809 * @param raw_pkt The whole raw packet data blob 850 * @param pad_len [out] The padding length used in the packet851 810 * 852 811 * @return A NTSTATUS error code … … 855 814 struct ncacn_packet *pkt, 856 815 DATA_BLOB *pkt_trailer, 857 size_t header_size, 858 DATA_BLOB *raw_pkt, 859 size_t *pad_len) 816 uint8_t header_size, 817 DATA_BLOB *raw_pkt) 860 818 { 861 819 struct schannel_state *schannel_auth; … … 869 827 DATA_BLOB data; 870 828 829 /* 830 * These check should be done in the caller. 831 */ 832 SMB_ASSERT(raw_pkt->length == pkt->frag_length); 833 SMB_ASSERT(header_size <= pkt->frag_length); 834 SMB_ASSERT(pkt_trailer->length < pkt->frag_length); 835 SMB_ASSERT((pkt_trailer->length + header_size) <= pkt->frag_length); 836 871 837 switch (auth->auth_level) { 872 838 case DCERPC_AUTH_LEVEL_PRIVACY: … … 882 848 break; 883 849 } 884 *pad_len = 0;885 850 return NT_STATUS_OK; 886 851 … … 891 856 return NT_STATUS_INVALID_PARAMETER; 892 857 } 893 *pad_len = 0;894 858 return NT_STATUS_OK; 895 859 … … 900 864 } 901 865 902 /* Paranioa checks for auth_length. */ 903 if (pkt->auth_length > pkt->frag_length) { 904 return NT_STATUS_INFO_LENGTH_MISMATCH; 905 } 906 if (((unsigned int)pkt->auth_length 907 + DCERPC_AUTH_TRAILER_LENGTH < (unsigned int)pkt->auth_length) || 908 ((unsigned int)pkt->auth_length 909 + DCERPC_AUTH_TRAILER_LENGTH < DCERPC_AUTH_TRAILER_LENGTH)) { 910 /* Integer wrap attempt. */ 911 return NT_STATUS_INFO_LENGTH_MISMATCH; 866 if (pkt->auth_length == 0) { 867 return NT_STATUS_INVALID_PARAMETER; 912 868 } 913 869 … … 918 874 } 919 875 876 if (auth_info.auth_type != auth->auth_type) { 877 return NT_STATUS_INVALID_PARAMETER; 878 } 879 880 if (auth_info.auth_level != auth->auth_level) { 881 return NT_STATUS_INVALID_PARAMETER; 882 } 883 884 if (auth_info.auth_context_id != auth->auth_context_id) { 885 return NT_STATUS_INVALID_PARAMETER; 886 } 887 888 pkt_trailer->length -= auth_length; 920 889 data = data_blob_const(raw_pkt->data + header_size, 921 pkt_trailer->length - auth_length);922 full_pkt = data_blob_const(raw_pkt->data, 923 raw_pkt->length - auth_info.credentials.length);890 pkt_trailer->length); 891 full_pkt = data_blob_const(raw_pkt->data, raw_pkt->length); 892 full_pkt.length -= auth_info.credentials.length; 924 893 925 894 switch (auth->auth_type) { … … 997 966 * are still both used in later calls */ 998 967 if (auth->auth_level == DCERPC_AUTH_LEVEL_PRIVACY) { 968 if (pkt_trailer->length != data.length) { 969 return NT_STATUS_INVALID_PARAMETER; 970 } 999 971 memcpy(pkt_trailer->data, data.data, data.length); 1000 972 } 1001 973 1002 *pad_len= auth_info.auth_pad_length;974 pkt_trailer->length -= auth_info.auth_pad_length; 1003 975 data_blob_free(&auth_info.credentials); 1004 976 return NT_STATUS_OK;
Note:
See TracChangeset
for help on using the changeset viewer.