(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-ldss.c) |
| |
| 267 | | | dissect_ldss_broadcast(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) |
| 268 | | | { |
| 269 | | | guint16 messageID; |
| 270 | | | guint8 digest_type; |
| 271 | | | guint8 compression; |
| 272 | | | guint32 cookie; |
| 273 | | | guint8 *digest; |
| 274 | | | guint64 size; |
| 275 | | | guint64 offset; |
| 276 | | | guint32 targetTime; |
| 277 | | | guint16 port; |
| 278 | | | guint16 rate; |
| 279 | | | guint16 messageDetail = INFERRED_NONE; |
| 280 | | | |
| 281 | | | proto_tree *ti, *ldss_tree; |
| 282 | | | |
| 283 | | | const gchar *packet_type, *packet_detail; |
| 284 | | | |
| 285 | | | messageID = tvb_get_ntohs (tvb, 0); |
| 286 | | | digest_type = tvb_get_guint8 (tvb, 2); |
| 287 | | | compression = tvb_get_guint8 (tvb, 3); |
| 288 | | | cookie = tvb_get_ntohl (tvb, 4); |
| 289 | | | digest = tvb_memdup (tvb, 8, DIGEST_LEN); |
| 290 | | | size = tvb_get_ntoh64 (tvb, 40); |
| 291 | | | offset = tvb_get_ntoh64 (tvb, 48); |
| 292 | | | targetTime = tvb_get_ntohl (tvb, 56); |
| 293 | | | port = tvb_get_ntohs (tvb, 64); |
| 294 | | | rate = tvb_get_ntohs (tvb, 66); |
| 295 | | | |
| 296 | | | packet_type = val_to_str(messageID, ldss_message_id_value, "unknown"); |
Ignored Return Value
The return value of val_to_str() is never checked in the highlighted execution scenario. - If the return value can indicate an error, the error will be ignored if the highlighted code executes.
- The return value of val_to_str() is checked 98% of the time in this project. CodeSonar is configured to enforce Ignored Return Value checks for any function whose return value is checked at least 96% of the time, unless the function is used fewer than 20 times. (To modify these thresholds, use configuration file parameters RETURN_CHECKER_SAMPLE_SIZE and RETURN_CHECKER_RATIO. To exempt val_to_str() from the Ignored Return Value check, use configuration file parameter RETURN_CHECKER_IGNORED_FUNCS).
Show: All events | Only primary events |
|
| 297 | | | |
| 298 | | | if (messageID == MESSAGE_ID_WILLSEND) { |
Event 2:
Taking true branch. messageID == 1 evaluates to true.
hide
|
|
| 299 | | | if (cookie == 0) { |
Event 3:
Taking false branch. cookie == 0 evaluates to false.
hide
|
|
| 300 | | | |
| 301 | | | |
| 302 | | | messageDetail = INFERRED_PEERSHUTDOWN; |
| 303 | | | } |
| 304 | | | else if (size == 0 && offset == 0) { |
| 305 | | | |
| 306 | | | messageDetail = INFERRED_WANDOWNLOAD; |
| 307 | | | } |
| 308 | | | else if (size > 0) { |
Event 5:
Skipping " if". size > 0 evaluates to false.
hide
|
|
| 309 | | | |
| 310 | | | if (size == offset) { |
| 311 | | | |
| 312 | | | messageDetail = INFERRED_OFFER; |
| 313 | | | } |
| 314 | | | else { |
| 315 | | | |
| 316 | | | messageDetail = INFERRED_PROMISE; |
| 317 | | | } |
| 318 | | | } |
| 319 | | | } |
| 320 | | | else if (messageID == MESSAGE_ID_NEEDFILE) { |
| 321 | | | messageDetail = INFERRED_SEARCH; |
| 322 | | | } |
| 323 | | | packet_detail = val_to_str(messageDetail, ldss_inferred_info, "unknown"); |
| 324 | | | |
| 325 | | | |
| 326 | | | if (check_col(pinfo->cinfo, COL_INFO)) { |
Event 6:
Skipping " if". check_col(...) evaluates to false.
hide
|
|
| 327 | | | col_add_fstr(pinfo->cinfo, COL_INFO, "LDSS Broadcast (%s%s)", |
| 328 | | | packet_type, |
| 329 | | | packet_detail); |
| 330 | | | } |
| 331 | | | |
| 332 | | | |
| 333 | | | |
| 334 | | | if (tree) { |
Event 7:
Taking true branch. tree evaluates to true.
hide
|
|
| 335 | | | ti = proto_tree_add_item(tree, proto_ldss, |
| 336 | | | tvb, 0, (tvb_length(tvb) > 72) ? tvb_length(tvb) : 72, FALSE); |
Event 8:
tvb_length(tvb) > 72 evaluates to true.
hide
|
|
| 337 | | | ldss_tree = proto_item_add_subtree(ti, ett_ldss_broadcast); |
| 338 | | | |
| 339 | | | ti = proto_tree_add_item(ldss_tree, hf_ldss_message_id, |
| 340 | | | tvb, 0, 2, FALSE); |
| 341 | | | ti = proto_tree_add_uint(ldss_tree, hf_ldss_message_detail, |
| 342 | | | tvb, 0, 0, messageDetail); |
| 343 | | | PROTO_ITEM_SET_GENERATED(ti);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/proto.h |
| |
325 | #define PROTO_ITEM_SET_GENERATED(proto_item) \ |
326 | ((proto_item) ? FI_SET_FLAG((proto_item)->finfo, FI_GENERATED) : 0) |
| |
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/proto.h |
| |
246 | #define FI_SET_FLAG(fi, flag) (fi->flags = fi->flags | flag) |
| |
|
Event 9:
ti evaluates to true.
hide
|
|
| 344 | | | ti = proto_tree_add_item(ldss_tree, hf_ldss_digest_type, |
| 345 | | | tvb, 2, 1, FALSE); |
| 346 | | | ti = proto_tree_add_item(ldss_tree, hf_ldss_compression, |
| 347 | | | tvb, 3, 1, FALSE); |
| 348 | | | ti = proto_tree_add_uint_format_value(ldss_tree, hf_ldss_cookie, |
| 349 | | | tvb, 4, 4, FALSE, |
| 350 | | | "0x%x%s", |
| 351 | | | cookie, |
| 352 | | | (cookie == 0) |
Event 10:
cookie == 0 evaluates to false.
hide
|
|
| 353 | | | ? " - shutdown (promises from this peer are no longer valid)" |
| 354 | | | : ""); |
| 355 | | | ti = proto_tree_add_item(ldss_tree, hf_ldss_digest, |
| 356 | | | tvb, 8, DIGEST_LEN, FALSE); |
| 357 | | | ti = proto_tree_add_item(ldss_tree, hf_ldss_size, |
| 358 | | | tvb, 40, 8, FALSE); |
| 359 | | | ti = proto_tree_add_item(ldss_tree, hf_ldss_offset, |
| 360 | | | tvb, 48, 8, FALSE); |
| 361 | | | ti = proto_tree_add_uint_format_value(ldss_tree, hf_ldss_target_time, |
| 362 | | | tvb, 56, 4, FALSE, |
| 363 | | | "%d:%02d:%02d", |
| 364 | | | (int)(targetTime / 3600), |
| 365 | | | (int)((targetTime / 60) % 60), |
| 366 | | | (int)(targetTime % 60)); |
| 367 | | | ti = proto_tree_add_item(ldss_tree, hf_ldss_reserved_1, |
| 368 | | | tvb, 60, 4, FALSE); |
| 369 | | | ti = proto_tree_add_uint_format_value(ldss_tree, hf_ldss_port, |
| 370 | | | tvb, 64, 2, FALSE, |
| 371 | | | "%d%s", |
| 372 | | | port, |
| 373 | | | (messageID == MESSAGE_ID_WILLSEND && |
Event 11:
messageID == 1 evaluates to true.
hide
|
|
| 374 | | | size > 0 && |
Event 12:
size > 0 evaluates to false.
hide
|
|
| 375 | | | size == offset) |
| 376 | | | ? " - file can be pulled at this TCP port" |
| 377 | | | : (messageID == MESSAGE_ID_NEEDFILE |
Event 13:
messageID == 0 evaluates to false.
hide
|
|
| 378 | | | ? " - file can be pushed to this TCP port" |
| 379 | | | : "")); |
| 380 | | | ti = proto_tree_add_uint_format_value(ldss_tree, hf_ldss_rate, |
| 381 | | | tvb, 66, 2, FALSE, |
| 382 | | | "%ld", |
| 383 | | | (rate > 0) |
Event 14:
rate > 0 evaluates to true.
hide
|
|
| 384 | | | ? (long)floor(exp(rate * G_LN2 / 2048))
x /usr/include/glib-2.0/glib/gtypes.h |
| |
124 | #define G_LN2 0.69314718055994530941723212145817656807550013436026 |
| |
|
| 385 | | | : 0); |
| 386 | | | ti = proto_tree_add_item(ldss_tree, hf_ldss_priority, |
| 387 | | | tvb, 68, 2, FALSE); |
| 388 | | | ti = proto_tree_add_item(ldss_tree, hf_ldss_property_count, |
| 389 | | | tvb, 70, 2, FALSE); |
| 390 | | | if (tvb_length(tvb) > 72) { |
Event 15:
Taking true branch. tvb_length(tvb) > 72 evaluates to true.
hide
|
|
| 391 | | | ti = proto_tree_add_item(ldss_tree, hf_ldss_properties, |
| 392 | | | tvb, 72, tvb_length(tvb) - 72, FALSE); |
| 393 | | | } |
| 394 | | | } |
| 395 | | | |
| 396 | | | |
| 397 | | | |
| 398 | | | |
| 399 | | | |
| 400 | | | |
| 401 | | | |
| 402 | | | |
| 403 | | | |
| 404 | | | |
| 405 | | | |
| 406 | | | |
| 407 | | | if (messageDetail != INFERRED_PEERSHUTDOWN && |
| 408 | | | (highest_num_seen == 0 || |
| 409 | | | highest_num_seen < pinfo->fd->num)) { |
| 410 | | | |
| 411 | | | ldss_broadcast_t *data; |
| 412 | | | |
| 413 | | | |
| 414 | | | data = se_alloc0(sizeof(ldss_broadcast_t)); |
| 415 | | | data->num = pinfo->fd->num; |
| 416 | | | data->ts = pinfo->fd->abs_ts; |
| 417 | | | data->message_id = messageID; |
| 418 | | | data->message_detail = messageDetail; |
| 419 | | | data->port = port; |
| 420 | | | data->size = size; |
| 421 | | | data->offset = offset; |
| 422 | | | data->compression = compression; |
| 423 | | | |
| 424 | | | data->file = se_alloc0(sizeof(ldss_file_t)); |
| 425 | | | data->file->digest = digest; |
| 426 | | | data->file->digest_type = digest_type; |
| 427 | | | |
| 428 | | | data->broadcaster = se_alloc0(sizeof(ldss_broadcaster_t)); |
| 429 | | | COPY_ADDRESS(&data->broadcaster->addr, &pinfo->src);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/address.h |
| |
107 | #define COPY_ADDRESS(to, from) { \ |
108 | guint8 *COPY_ADDRESS_data; \ |
109 | (to)->type = (from)->type; \ |
110 | (to)->len = (from)->len; \ |
111 | COPY_ADDRESS_data = g_malloc((from)->len); \ |
112 | memcpy(COPY_ADDRESS_data, (from)->data, (from)->len); \ |
113 | (to)->data = COPY_ADDRESS_data; \ |
114 | } |
| |
|
| 430 | | | data->broadcaster->port = port; |
| 431 | | | |
| 432 | | | |
| 433 | | | if (port > 0) { |
Event 17:
Taking true branch. port > 0 evaluates to true.
hide
|
|
| 434 | | | prepare_ldss_transfer_conv(data); |
| 435 | | | } |
| 436 | | | |
| 437 | | | |
| 438 | | | highest_num_seen = pinfo->fd->num; |
| 439 | | | } |
| 440 | | | |
| 441 | | | return tvb_length(tvb); |
| 442 | | | } |
| |