Text   |  XML   |  ReML   |   Visible Warnings:

Unreachable Control Flow  at proto.c:1290

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

proto_tree_new_item

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/proto.c)expand/collapse
Show more  
 1067  static proto_item *
 1068  proto_tree_new_item(field_info *new_fi, proto_tree *tree, int hfindex,
 1069      tvbuff_t *tvb, gint start, gint length, gboolean little_endian)
 1070  {
 1071          proto_item      *pi;
 1072          guint32         value, n;
 1073          float           floatval;
 1074          double          doubleval;
 1075          char            *string;
 1076          GHashTable      *hash;
 1077          GPtrArray       *ptrs;
 1078   
 1079          /* there is a possibility here that we might raise an exception 
 1080           * and thus would lose track of the field_info.
 1081           * store it in a temp so that if we come here again we can reclaim 
 1082           * the field_info without leaking memory.
 1083           */
 1084          /* XXX this only keeps track of one field_info struct,
 1085             if we ever go multithreaded for calls to this function 
 1086             we have to change this code to use per thread variable.
 1087          */
 1088          if(field_info_tmp){
 1089                  /* oops, last one we got must have been lost due 
 1090                   * to an exception.
 1091                   * good thing we saved it, now we can reverse the 
 1092                   * memory leak and reclaim it.
 1093                   */
 1094                  SLAB_FREE(field_info_tmp, field_info);
 1095          }
 1096          /* we might throw an exception, keep track of this one 
 1097           * across the "dangerous" section below.
 1098          */
 1099          field_info_tmp=new_fi;
 1100   
 1101          switch(new_fi->hfinfo->type) {
 1102                  case FT_NONE:
 1103                          /* no value to set for FT_NONE */
 1104                          break;
 1105   
 1106                  case FT_PROTOCOL:
 1107                          proto_tree_set_protocol_tvb(new_fi, tvb);
 1108                          break;
 1109   
 1110                  case FT_BYTES:
 1111                          proto_tree_set_bytes_tvb(new_fi, tvb, start, length);
 1112                          break;
 1113   
 1114                  case FT_UINT_BYTES:
 1115                          n = get_uint_value(tvb, start, length, little_endian);
 1116                          proto_tree_set_bytes_tvb(new_fi, tvb, start + length, n);
 1117   
 1118                          /* Instead of calling proto_item_set_len(), since we don't yet 
 1119                           * have a proto_item, we set the field_info's length ourselves. */
 1120                          new_fi->length = n + length;
 1121                          break;
 1122   
 1123                  case FT_BOOLEAN:
 1124                          proto_tree_set_boolean(new_fi,
 1125                              get_uint_value(tvb, start, length, little_endian));
 1126                          break;
 1127   
 1128                  /* XXX - make these just FT_UINT? */
 1129                  case FT_UINT8:
 1130                  case FT_UINT16:
 1131                  case FT_UINT24:
 1132                  case FT_UINT32:
 1133                          proto_tree_set_uint(new_fi,
 1134                              get_uint_value(tvb, start, length, little_endian));
 1135                          break;
 1136   
 1137                  case FT_INT64:
 1138                  case FT_UINT64:
 1139                          DISSECTOR_ASSERT( length <= 8 && length >= 1);
 1140                          proto_tree_set_uint64_tvb(new_fi, tvb, start, length, little_endian);
 1141                          break;
 1142   
 1143                  /* XXX - make these just FT_INT? */
 1144                  case FT_INT8:
 1145                  case FT_INT16:
 1146                  case FT_INT24:
 1147                  case FT_INT32:
 1148                          proto_tree_set_int(new_fi,
 1149                              get_int_value(tvb, start, length, little_endian));
 1150                          break;
 1151   
 1152                  case FT_IPv4:
 1153                          DISSECTOR_ASSERT(length == 4);
 1154                          value = tvb_get_ipv4(tvb, start);
 1155                          proto_tree_set_ipv4(new_fi, little_endian ? GUINT32_SWAP_LE_BE(value) : value);
 1156                          break;
 1157   
 1158                  case FT_IPXNET:
 1159                          DISSECTOR_ASSERT(length == 4);
 1160                          proto_tree_set_ipxnet(new_fi,
 1161                              get_uint_value(tvb, start, 4, FALSE));
 1162                          break;
 1163   
 1164                  case FT_IPv6:
 1165                          DISSECTOR_ASSERT(length == 16);
 1166                          proto_tree_set_ipv6_tvb(new_fi, tvb, start);
 1167                          break;
 1168   
 1169                  case FT_ETHER:
 1170                          DISSECTOR_ASSERT(length == 6);
 1171                          proto_tree_set_ether_tvb(new_fi, tvb, start);
 1172                          break;
 1173   
 1174                  case FT_GUID:
 1175                          DISSECTOR_ASSERT(length == 16);
 1176                          proto_tree_set_guid_tvb(new_fi, tvb, start, little_endian);
 1177                          break;
 1178   
 1179                  case FT_OID:
 1180                          proto_tree_set_oid_tvb(new_fi, tvb, start, length);
 1181                          break;
 1182   
 1183                  case FT_FLOAT:
 1184                          DISSECTOR_ASSERT(length == 4);
 1185                          if (little_endian)
 1186                                  floatval = tvb_get_letohieee_float(tvb, start);
 1187                          else 
 1188                                  floatval = tvb_get_ntohieee_float(tvb, start);
 1189                          proto_tree_set_float(new_fi, floatval);
 1190                          break;
 1191   
 1192                  case FT_DOUBLE:
 1193                          DISSECTOR_ASSERT(length == 8);
 1194                          if (little_endian)
 1195                                  doubleval = tvb_get_letohieee_double(tvb, start);
 1196                          else 
 1197                                  doubleval = tvb_get_ntohieee_double(tvb, start);
 1198                          proto_tree_set_double(new_fi, doubleval);
 1199                          break;
 1200   
 1201                  case FT_STRING:
 1202                          proto_tree_set_string_tvb(new_fi, tvb, start, length);
 1203                          break;
 1204   
 1205                  case FT_STRINGZ:
 1206                          DISSECTOR_ASSERT(length >= -1);
 1207                          /* Instead of calling proto_item_set_len(),
 1208                           * since we don't yet have a proto_item, we 
 1209                           * set the field_info's length ourselves.
 1210                           *
 1211                           * XXX - our caller can't use that length to
 1212                           * advance an offset unless they arrange that 
 1213                           * there always be a protocol tree into which
 1214                           * we're putting this item.
 1215                           */
 1216                          if (length == -1) {
 1217                                  /* This can throw an exception */
 1218                                  length = tvb_strsize(tvb, start);
 1219   
 1220                                  string = ep_alloc(length);
 1221   
 1222                                  tvb_memcpy(tvb, string, start, length);
 1223                          } else if (length == 0) {
 1224                                  string = "[Empty]";
 1225                          } else {
 1226                                  /* In this case, length signifies
 1227                                   * the length of the string.
 1228                                   *
 1229                                   * This could either be a null-padded
 1230                                   * string, which doesn't necessarily 
 1231                                   * have a '\0' at the end, or a
 1232                                   * null-terminated string, with a
 1233                                   * trailing '\0'.  (Yes, there are
 1234                                   * cases where you have a string
 1235                                   * that's both counted and null-
 1236
1246
Show [ Lines 1236 to 1246 omitted. ]
 1247                                   * throw an exception if there's no 
 1248                                   * trailing '\0'?)  Therefore, we 
 1249                                   * allocate a buffer of length 
 1250                                   * "length+1", and put in a trailing 
 1251                                   * '\0', just to be safe.
 1252                                   *
 1253                                   * (XXX - this would change if
 1254                                   * we made string values counted 
 1255                                   * rather than null-terminated.)
 1256                                   */
 1257                                  string = tvb_get_ephemeral_string(tvb,
 1258                                                                            start,
 1259                                                                            length);
 1260                          }
 1261                          new_fi->length = length;
 1262                          proto_tree_set_string(new_fi, string);
 1263                          break;
 1264   
 1265                  case FT_EBCDIC:
 1266                          proto_tree_set_ebcdic_string_tvb(new_fi, tvb, start, length);
 1267                          break;
 1268   
 1269                  case FT_UINT_STRING:
 1270                          n = get_uint_value(tvb, start, length, little_endian);
 1271                          proto_tree_set_string_tvb(new_fi, tvb, start + length, n);
 1272   
 1273                          /* Instead of calling proto_item_set_len(), since we
 1274                           * don't yet have a proto_item, we set the 
 1275                           * field_info's length ourselves.
 1276                           *
 1277                           * XXX - our caller can't use that length to
 1278                           * advance an offset unless they arrange that 
 1279                           * there always be a protocol tree into which
 1280                           * we're putting this item.
 1281                           */
 1282                          new_fi->length = n + length;
 1283                          break;
 1284   
 1285                  default:
 1286                          g_error("new_fi->hfinfo->type %d (%s) not handled\n",
 1287                                          new_fi->hfinfo->type,
 1288                                          ftype_name(new_fi->hfinfo->type));
 1289                          DISSECTOR_ASSERT_NOT_REACHED();
 1290                          break;
 1291          }
 1292   
 1293          /* Don't add new node to proto_tree until now so that any exceptions 
 1294           * raised by a tvbuff access method doesn't leave junk in the proto_tree. */
 1295          pi = proto_tree_add_node(tree, new_fi);
 1296   
 1297          /* we did not raise an exception so we dont have to remember this 
 1298           * field_info struct any more.
 1299           */
 1300          field_info_tmp=NULL;
 1301   
 1302          /* If the proto_tree wants to keep a record of this finfo 
 1303           * for quick lookup, then record it. */
 1304          if (new_fi->hfinfo->ref_count) {
 1305                  /*HERE*/
 1306                  hash = PTREE_DATA(tree)->interesting_hfids;
 1307                  ptrs = g_hash_table_lookup(hash, GINT_TO_POINTER(hfindex));
 1308                  if (ptrs) {
 1309                          g_ptr_array_add(ptrs, new_fi);
 1310                  }
 1311          }
 1312   
 1313          return pi;
 1314  }
Show more  




Change Warning 1206.31762 : Unreachable Control Flow

Priority:
State:
Finding:
Owner:
Note: