Text   |  XML   |  ReML   |   Visible Warnings:

Null Test After Dereference  at packet-dcm.c:5044

No properties have been set. | edit properties
Jump to warning location ↓ warning details...
Show Events | Options

dissect_dcm_pdv_header

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-dcm.c)expand/collapse
Show more  
 4926  dissect_dcm_pdv_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
 4927                         dcm_state_assoc_t *assoc, guint32 offset, dcm_state_pdv_t **pdv)
 4928  {
 4929      /* Dissect Context and Flags of a PDV and create new PDV stucture */
 4930   
 4931      proto_item *pdv_ctx_pitem = NULL;
 4932      proto_item *pdv_flags_pitem = NULL;
 4933   
 4934      dcm_state_pctx_t    *pctx = NULL;
 4935      dcm_state_pdv_t     *pdv_first_data = NULL;
 4936   
 4937      const gchar *desc_flag = NULL;      /* Flag Description in tree */
 4938      gchar *desc_header = NULL;          /* Used for PDV description */
 4939   
 4940      guint8  flags = 0;
 4941      guint8  pctx_id = 0;
 4942   
 4943      /* 1 Byte Context */
 4944      pctx_id = tvb_get_guint8(tvb, offset);
 4945      pctx = dcm_state_pctx_get(assoc, pctx_id, FALSE);
 4946   
 4947      if (pctx && pctx->xfer_uid) {
 4948          proto_tree_add_uint_format(tree, hf_dcm_pdv_ctx, tvb, offset, 1,
 4949              pctx_id, "Context: 0x%02x (%s, %s)", pctx_id,
 4950          dcm_uid_or_desc(pctx->xfer_uid, pctx->xfer_desc),
 4951          dcm_uid_or_desc(pctx->abss_uid, pctx->abss_desc));
 4952      }
 4953      else {
 4954          pdv_ctx_pitem=proto_tree_add_uint_format(tree, hf_dcm_pdv_ctx, tvb,  offset, 1,
 4955              pctx_id, "Context: 0x%02x not found. A-ASSOCIATE request not found in capture.", pctx_id);
 4956   
 4957          expert_add_info_format(pinfo, pdv_ctx_pitem, PI_MALFORMED, PI_ERROR, "Invalid Presentation Context ID");
 4958   
 4959          /* Create fake PCTX and guess Syntax ILE, ELE, EBE */
 4960          pctx = dcm_state_pctx_new(assoc, pctx_id);
 4961   
 4962          /* To be done: Guess Syntax */
 4963          pctx->syntax = DCM_UNK;
 4964      }
 4965      offset +=1;
 4966   
 4967      /* Create PDV structure:
 4968   
 4969         Since we can have multiple PDV per packet (offset) and 
 4970         multiple merged packets per PDV (tvb->raw_offset)
 4971         we need both values to uniquely identify a PDV
 4972      */
 4973   
 4974      *pdv = dcm_state_pdv_get(pctx, pinfo->fd->num, tvb->raw_offset+offset, TRUE);
 4975      if (*pdv == NULL) {
 4976          return 0;                   /* Failed to allocate memory */
 4977      }
 4978   
 4979      /* 1 Byte Flag */
 4980      flags = tvb_get_guint8(tvb, offset);
 4981   
 4982      (*pdv)->pctx_id = pctx_id;          /* TBD: Required for export */
 4983   
 4984      desc_header=se_alloc0(MAX_BUF_LEN); /* Valid for this capture, since we return this buffer */
 4985   
 4986      switch (flags) {
 4987      case 0:     /* 00 */
 4988          desc_flag = "Data, More Fragments";
 4989   
 4990          (*pdv)->is_flagvalid = TRUE;
 4991          (*pdv)->is_command = FALSE;
 4992          (*pdv)->is_last_fragment = FALSE;
 4993          (*pdv)->syntax = pctx->syntax;      /* Inherit syntax for data PDVs*/
 4994          break;
 4995   
 4996      case 2:     /* 10 */
 4997          desc_flag = "Data, Last Fragment";
 4998   
 4999          (*pdv)->is_flagvalid = TRUE;
 5000          (*pdv)->is_command = FALSE;
 5001          (*pdv)->is_last_fragment = TRUE;
 5002          (*pdv)->syntax = pctx->syntax;      /* Inherit syntax for data PDVs*/
 5003          break;
 5004   
 5005      case 1:     /* 01 */
 5006          desc_flag = "Command, More Fragments";
 5007          g_snprintf(desc_header, MAX_BUF_LEN, "Command");                /* Will be overwritten with real command tag */
 5008   
 5009          (*pdv)->is_flagvalid = TRUE;
 5010          (*pdv)->is_command = TRUE;
 5011          (*pdv)->is_last_fragment = FALSE;
 5012          (*pdv)->syntax = DCM_ILE;           /* Command tags are always little endian*/
 5013          break;
 5014   
 5015      case 3:     /* 11 */
 5016          desc_flag = "Command, Last Fragment";
 5017          g_snprintf(desc_header, MAX_BUF_LEN, "Command");
 5018   
 5019          (*pdv)->is_flagvalid = TRUE;
 5020          (*pdv)->is_command = TRUE;
 5021          (*pdv)->is_last_fragment = TRUE;
 5022          (*pdv)->syntax = DCM_ILE;           /* Command tags are always little endian*/
 5023          break;
 5024   
 5025      default:
 5026          desc_flag = "Invalid Flags";
 5027          g_snprintf(desc_header, MAX_BUF_LEN, "Invalid Flags");
 5028   
 5029          (*pdv)->is_flagvalid = FALSE;
 5030          (*pdv)->is_command = FALSE;
 5031          (*pdv)->is_last_fragment = FALSE;
 5032          (*pdv)->syntax = DCM_UNK;
 5033      }
 5034   
 5035      if (flags == 0 || flags == 2) {
 5036          /* Data PDV */
 5037          pdv_first_data = dcm_state_pdv_get_obj_start(*pdv);
 5038   
 5039          if (pdv_first_data->prev && pdv_first_data->prev->is_command) {
 5040              /* Every Data PDV sequence should be preceeded by a Command PDV,
 5041                 so we should always hit this for a correct capture 
 5042              */
 5043   
 5044              if (pctx && pctx->abss_desc && g_str_has_suffix(pctx->abss_desc, "Storage")) {
 5045                  /* Should be done far more intelligent, e.g. does not catch the (Retired) ones */
 5046                  if (flags == 0) {
 5047                      g_snprintf(desc_header, MAX_BUF_LEN, "%s (more fragments)", pctx->abss_desc);
 5048                  }
 5049                  else {
 5050                      g_snprintf(desc_header, MAX_BUF_LEN, "%s", pctx->abss_desc);
 5051                  }
 5052                  (*pdv)->is_storage = TRUE;
 5053              }
 5054              else {
 5055                  /* Use previous command and append DATA*/
 5056                  g_snprintf(desc_header, MAX_BUF_LEN, "%s-DATA", pdv_first_data->prev->desc);
 5057              }
 5058          }
 5059          else {
 5060              g_snprintf(desc_header, MAX_BUF_LEN, "DATA");
 5061          }
 5062      }
 5063   
 5064      (*pdv)->desc = desc_header;
 5065   
 5066      pdv_flags_pitem = proto_tree_add_uint_format(tree, hf_dcm_pdv_flags, tvb, offset, 1,
 5067          flags, "Flags: 0x%02x (%s)", flags, desc_flag);
 5068   
 5069      if (flags>3) {
 5070          expert_add_info_format(pinfo, pdv_flags_pitem, PI_MALFORMED, PI_ERROR, "Invalid Flags");
 5071      }
 5072      offset +=1;
 5073   
 5074      return offset;
 5075  }
Show more  




Change Warning 2184.31465 : Null Test After Dereference

Priority:
State:
Finding:
Owner:
Note: