(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-mikey.c) |
| |
| 1254 | | | dissect_mikey(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) |
| 1255 | | | { |
| 1256 | | | proto_item *ti = NULL; |
| 1257 | | | proto_tree *mikey_tree = NULL; |
| 1258 | | | int offset = 0; |
| 1259 | | | int next_payload_offset; |
| 1260 | | | tvbuff_t *subtvb = NULL; |
| 1261 | | | int payload = -1; |
| 1262 | | | mikey_t *mikey; |
| 1263 | | | |
| 1264 | | | mikey = p_get_proto_data(pinfo->fd, proto_mikey); |
| 1265 | | | |
| 1266 | | | if (!mikey) { |
| 1267 | | | mikey = se_alloc0(sizeof(mikey_t)); |
| 1268 | | | mikey->type = -1; |
| 1269 | | | p_add_proto_data(pinfo->fd, proto_mikey, mikey); |
| 1270 | | | } |
| 1271 | | | |
| 1272 | | | |
| 1273 | | | tvb_ensure_bytes_exist(tvb, offset, 3); |
| 1274 | | | next_payload_offset = offset+2; |
| 1275 | | | payload = -1; |
Useless Assignment
This code assigns the variable the same value it already had. |
|
| 1276 | | | |
| 1277 | | | if (tree) { |
| 1278 | | | ti = proto_tree_add_item(tree, proto_mikey, tvb, 0, -1, FALSE); |
| 1279 | | | mikey_tree = proto_item_add_subtree(ti, ett_mikey); |
| 1280 | | | } |
| 1281 | | | |
| 1282 | | | while (payload != 0) { |
| 1283 | | | int len; |
| 1284 | | | proto_item *sub_ti = NULL; |
| 1285 | | | proto_tree *mikey_payload_tree = NULL; |
| 1286 | | | int next_payload; |
| 1287 | | | |
| 1288 | | | next_payload = tvb_get_guint8(tvb, next_payload_offset); |
| 1289 | | | len = tvb_length_remaining(tvb, offset); |
| 1290 | | | subtvb = tvb_new_subset(tvb, offset, len, len); |
| 1291 | | | |
| 1292 | | | if (mikey_tree) { |
| 1293 | | | int hf = payload; |
| 1294 | | | |
| 1295 | | | if (hf >= PL_MAX) |
| 1296 | | | return -1; |
| 1297 | | | |
| 1298 | | | if (hf == -1) |
| 1299 | | | hf = 0; |
| 1300 | | | |
| 1301 | | | sub_ti = proto_tree_add_item(mikey_tree, hf_mikey_pl[hf], subtvb, 0, -1, FALSE); |
| 1302 | | | |
| 1303 | | | mikey_payload_tree = proto_item_add_subtree(sub_ti, ett_mikey_payload); |
| 1304 | | | if (payload != PL_HDR && payload != PL_SIGN) |
| 1305 | | | add_next_payload(tvb, mikey_payload_tree, next_payload_offset); |
| 1306 | | | } |
| 1307 | | | |
| 1308 | | | len = dissect_payload(payload, mikey, subtvb, pinfo, mikey_payload_tree); |
| 1309 | | | if (len < 0) { |
| 1310 | | | return -1; |
| 1311 | | | } |
| 1312 | | | |
| 1313 | | | if (sub_ti) |
| 1314 | | | proto_item_set_len(sub_ti, len); |
| 1315 | | | |
| 1316 | | | if (payload == PL_SIGN) |
| 1317 | | | break; |
| 1318 | | | |
| 1319 | | | payload = next_payload; |
| 1320 | | | offset += len; |
| 1321 | | | next_payload_offset = offset; |
| 1322 | | | } |
| 1323 | | | |
| 1324 | | | if (ti) { |
| 1325 | | | proto_item_append_text(ti, ": %s", val_to_str(mikey->type, data_type_vals, "Unknown")); |
| 1326 | | | } |
| 1327 | | | |
| 1328 | | | if (check_col(pinfo->cinfo, COL_PROTOCOL)) |
| 1329 | | | col_append_str(pinfo->cinfo, COL_PROTOCOL, "/MIKEY"); |
| 1330 | | | |
| 1331 | | | if (check_col(pinfo->cinfo, COL_INFO)) |
| 1332 | | | col_append_fstr(pinfo->cinfo, COL_INFO, ", Mikey: %s", val_to_str(mikey->type, data_type_vals, "Unknown")); |
| 1333 | | | |
| 1334 | | | |
| 1335 | | | return tvb_length(tvb); |
| 1336 | | | } |
| |