Print this page
10103 libmlrpc needs smatch fixes


   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.

  24  */
  25 
  26 /*
  27  * Server side RPC handler.
  28  */
  29 
  30 #include <sys/byteorder.h>
  31 #include <sys/uio.h>
  32 #include <errno.h>
  33 #include <synch.h>
  34 #include <stdlib.h>
  35 #include <strings.h>
  36 #include <string.h>
  37 #include <thread.h>
  38 
  39 #include <libmlrpc.h>
  40 
  41 #define NDR_PIPE_SEND(np, buf, len) \
  42         ((np)->np_send)((np), (buf), (len))
  43 #define NDR_PIPE_RECV(np, buf, len) \


 623                     mxa->recv_hdr.alter_context_hdr.assoc_group_id;
 624                 break;
 625 
 626         default:
 627                 hdr->ptype = 0xFF;
 628         }
 629 }
 630 
 631 /*
 632  * Signal an RPC fault. The stream is reset and we overwrite whatever
 633  * was in the response header with the fault information.
 634  */
 635 static void
 636 ndr_reply_fault(ndr_xa_t *mxa, unsigned long drc)
 637 {
 638         ndr_common_header_t *rhdr = &mxa->recv_hdr.common_hdr;
 639         ndr_common_header_t *hdr = &mxa->send_hdr.common_hdr;
 640         ndr_stream_t *nds = &mxa->send_nds;
 641         unsigned long fault_status;
 642 
 643         NDS_RESET(nds);
 644 
 645         hdr->rpc_vers = 5;
 646         hdr->rpc_vers_minor = 0;
 647         hdr->pfc_flags = NDR_PFC_FIRST_FRAG + NDR_PFC_LAST_FRAG;
 648         hdr->packed_drep = rhdr->packed_drep;
 649         hdr->frag_length = sizeof (mxa->send_hdr.fault_hdr);
 650         hdr->auth_length = 0;
 651         hdr->call_id = rhdr->call_id;
 652 #ifdef _BIG_ENDIAN
 653         hdr->packed_drep.intg_char_rep = NDR_REPLAB_CHAR_ASCII
 654             | NDR_REPLAB_INTG_BIG_ENDIAN;
 655 #else
 656         hdr->packed_drep.intg_char_rep = NDR_REPLAB_CHAR_ASCII
 657             | NDR_REPLAB_INTG_LITTLE_ENDIAN;
 658 #endif
 659 
 660         switch (drc & NDR_DRC_MASK_SPECIFIER) {
 661         case NDR_DRC_FAULT_OUT_OF_MEMORY:
 662         case NDR_DRC_FAULT_ENCODE_TOO_BIG:
 663                 fault_status = NDR_FAULT_NCA_OUT_ARGS_TOO_BIG;




   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
  24  * Copyright (c) 2018, Joyent, Inc.
  25  */
  26 
  27 /*
  28  * Server side RPC handler.
  29  */
  30 
  31 #include <sys/byteorder.h>
  32 #include <sys/uio.h>
  33 #include <errno.h>
  34 #include <synch.h>
  35 #include <stdlib.h>
  36 #include <strings.h>
  37 #include <string.h>
  38 #include <thread.h>
  39 
  40 #include <libmlrpc.h>
  41 
  42 #define NDR_PIPE_SEND(np, buf, len) \
  43         ((np)->np_send)((np), (buf), (len))
  44 #define NDR_PIPE_RECV(np, buf, len) \


 624                     mxa->recv_hdr.alter_context_hdr.assoc_group_id;
 625                 break;
 626 
 627         default:
 628                 hdr->ptype = 0xFF;
 629         }
 630 }
 631 
 632 /*
 633  * Signal an RPC fault. The stream is reset and we overwrite whatever
 634  * was in the response header with the fault information.
 635  */
 636 static void
 637 ndr_reply_fault(ndr_xa_t *mxa, unsigned long drc)
 638 {
 639         ndr_common_header_t *rhdr = &mxa->recv_hdr.common_hdr;
 640         ndr_common_header_t *hdr = &mxa->send_hdr.common_hdr;
 641         ndr_stream_t *nds = &mxa->send_nds;
 642         unsigned long fault_status;
 643 
 644         (void) NDS_RESET(nds);
 645 
 646         hdr->rpc_vers = 5;
 647         hdr->rpc_vers_minor = 0;
 648         hdr->pfc_flags = NDR_PFC_FIRST_FRAG + NDR_PFC_LAST_FRAG;
 649         hdr->packed_drep = rhdr->packed_drep;
 650         hdr->frag_length = sizeof (mxa->send_hdr.fault_hdr);
 651         hdr->auth_length = 0;
 652         hdr->call_id = rhdr->call_id;
 653 #ifdef _BIG_ENDIAN
 654         hdr->packed_drep.intg_char_rep = NDR_REPLAB_CHAR_ASCII
 655             | NDR_REPLAB_INTG_BIG_ENDIAN;
 656 #else
 657         hdr->packed_drep.intg_char_rep = NDR_REPLAB_CHAR_ASCII
 658             | NDR_REPLAB_INTG_LITTLE_ENDIAN;
 659 #endif
 660 
 661         switch (drc & NDR_DRC_MASK_SPECIFIER) {
 662         case NDR_DRC_FAULT_OUT_OF_MEMORY:
 663         case NDR_DRC_FAULT_ENCODE_TOO_BIG:
 664                 fault_status = NDR_FAULT_NCA_OUT_ARGS_TOO_BIG;