(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-sip.c) |
| |
| 3264 | | | guint sip_is_packet_resend(packet_info *pinfo, |
| 3265 | | | gchar *cseq_method, |
| 3266 | | | gchar *call_id, |
| 3267 | | | guchar cseq_number_set, |
| 3268 | | | guint32 cseq_number, line_type_t line_type) |
| 3269 | | | { |
| 3270 | | | guint32 cseq_to_compare = 0; |
| 3271 | | | sip_hash_key key; |
| 3272 | | | sip_hash_key *p_key = 0; |
| 3273 | | | sip_hash_value *p_val = 0; |
| 3274 | | | sip_frame_result_value *sip_frame_result = NULL; |
| 3275 | | | guint result = 0; |
| 3276 | | | |
| 3277 | | | |
| 3278 | | | if (pinfo->ptype != PT_UDP) |
| 3279 | | | { |
| 3280 | | | return 0; |
| 3281 | | | } |
| 3282 | | | |
| 3283 | | | |
| 3284 | | | |
| 3285 | | | if (pinfo->in_error_pkt) |
| 3286 | | | { |
| 3287 | | | return 0; |
| 3288 | | | } |
| 3289 | | | |
| 3290 | | | |
| 3291 | | | |
| 3292 | | | if (!cseq_number_set) |
| 3293 | | | { |
| 3294 | | | return 0; |
| 3295 | | | } |
| 3296 | | | |
| 3297 | | | |
| 3298 | | | if (pinfo->fd->flags.visited) |
| 3299 | | | { |
| 3300 | | | sip_frame_result = (sip_frame_result_value*)p_get_proto_data(pinfo->fd, proto_sip); |
| 3301 | | | if (sip_frame_result != NULL) |
| 3302 | | | { |
| 3303 | | | return sip_frame_result->original_frame_num; |
| 3304 | | | } |
| 3305 | | | else |
| 3306 | | | { |
| 3307 | | | return 0; |
| 3308 | | | } |
| 3309 | | | } |
| 3310 | | | |
| 3311 | | | |
| 3312 | | | |
| 3313 | | | |
| 3314 | | | g_strlcpy(key.call_id, call_id, MAX_CALL_ID_SIZE); |
| 3315 | | | |
| 3316 | | | |
| 3317 | | | |
| 3318 | | | |
| 3319 | | | SET_ADDRESS(&key.dest_address, pinfo->net_dst.type, pinfo->net_dst.len,
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/address.h |
| |
66 | #define SET_ADDRESS(addr, addr_type, addr_len, addr_data) { \ |
67 | (addr)->type = (addr_type); \ |
68 | (addr)->len = (addr_len); \ |
69 | (addr)->data = (addr_data); \ |
70 | } |
| |
|
| 3320 | | | pinfo->net_dst.data); |
| 3321 | | | SET_ADDRESS(&key.source_address, pinfo->net_src.type,
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/address.h |
| |
66 | #define SET_ADDRESS(addr, addr_type, addr_len, addr_data) { \ |
67 | (addr)->type = (addr_type); \ |
68 | (addr)->len = (addr_len); \ |
69 | (addr)->data = (addr_data); \ |
70 | } |
| |
|
| 3322 | | | pinfo->net_src.len, pinfo->net_src.data); |
| 3323 | | | key.dest_port = pinfo->destport; |
| 3324 | | | key.source_port = pinfo->srcport; |
| 3325 | | | |
| 3326 | | | |
| 3327 | | | p_val = (sip_hash_value*)g_hash_table_lookup(sip_hash, &key); |
| 3328 | | | |
| 3329 | | | if (p_val) |
| 3330 | | | { |
| 3331 | | | |
| 3332 | | | cseq_to_compare = p_val->cseq; |
| 3333 | | | |
| 3334 | | | |
| 3335 | | | |
| 3336 | | | if (cseq_number != p_val->cseq) |
| 3337 | | | { |
| 3338 | | | p_val->cseq = cseq_number; |
| 3339 | | | g_strlcpy(p_val->method, cseq_method, MAX_CSEQ_METHOD_SIZE); |
| 3340 | | | p_val->transaction_state = nothing_seen; |
| 3341 | | | p_val->frame_number = 0; |
| 3342 | | | if (line_type == REQUEST_LINE) |
| 3343 | | | { |
| 3344 | | | p_val->request_time = pinfo->fd->abs_ts; |
| 3345 | | | } |
| 3346 | | | } |
| 3347 | | | } |
| 3348 | | | else |
| 3349 | | | { |
| 3350 | | | |
| 3351 | | | |
| 3352 | | | |
| 3353 | | | p_key = se_alloc(sizeof(sip_hash_key)); |
| 3354 | | | p_val = se_alloc(sizeof(sip_hash_value)); |
Ignored Return Value
The return value of se_alloc() 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 se_alloc() is checked 99% 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 se_alloc() from the Ignored Return Value check, use configuration file parameter RETURN_CHECKER_IGNORED_FUNCS).
Show: All events | Only primary events |
|
| 3355 | | | |
| 3356 | | | |
| 3357 | | | if (!p_key || !p_val) |
Event 2:
Taking true branch. p_key evaluates to false.
hide
|
|
| 3358 | | | { |
| 3359 | | | return 0; |
| 3360 | | | } |
| 3361 | | | |
| 3362 | | | |
| 3363 | | | g_snprintf(p_key->call_id, MAX_CALL_ID_SIZE, "%s", call_id); |
| 3364 | | | SE_COPY_ADDRESS(&(p_key->dest_address), &pinfo->net_dst);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/address.h |
| |
116 | #define SE_COPY_ADDRESS(to, from) { \ |
117 | guint8 *SE_COPY_ADDRESS_data; \ |
118 | (to)->type = (from)->type; \ |
119 | (to)->len = (from)->len; \ |
120 | SE_COPY_ADDRESS_data = se_alloc((from)->len); \ |
121 | memcpy(SE_COPY_ADDRESS_data, (from)->data, (from)->len); \ |
122 | (to)->data = SE_COPY_ADDRESS_data; \ |
123 | } |
| |
|
| 3365 | | | SE_COPY_ADDRESS(&(p_key->source_address), &pinfo->net_src);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/address.h |
| |
116 | #define SE_COPY_ADDRESS(to, from) { \ |
117 | guint8 *SE_COPY_ADDRESS_data; \ |
118 | (to)->type = (from)->type; \ |
119 | (to)->len = (from)->len; \ |
120 | SE_COPY_ADDRESS_data = se_alloc((from)->len); \ |
121 | memcpy(SE_COPY_ADDRESS_data, (from)->data, (from)->len); \ |
122 | (to)->data = SE_COPY_ADDRESS_data; \ |
123 | } |
| |
|
| 3366 | | | p_key->dest_port = pinfo->destport; |
| 3367 | | | p_key->source_port = pinfo->srcport; |
| 3368 | | | |
| 3369 | | | p_val->cseq = cseq_number; |
| 3370 | | | g_strlcpy(p_val->method, cseq_method, MAX_CSEQ_METHOD_SIZE); |
| 3371 | | | p_val->transaction_state = nothing_seen; |
| 3372 | | | p_val->frame_number = 0; |
| 3373 | | | if (line_type == REQUEST_LINE) |
| 3374 | | | { |
| 3375 | | | p_val->request_time = pinfo->fd->abs_ts; |
| 3376 | | | } |
| 3377 | | | |
| 3378 | | | |
| 3379 | | | g_hash_table_insert(sip_hash, p_key, p_val); |
| 3380 | | | |
| 3381 | | | |
| 3382 | | | cseq_to_compare = 0; |
| 3383 | | | } |
| 3384 | | | |
| 3385 | | | |
| 3386 | | | |
| 3387 | | | |
| 3388 | | | |
| 3389 | | | |
| 3390 | | | |
| 3391 | | | |
| 3392 | | | if ((line_type == REQUEST_LINE) && (cseq_number == cseq_to_compare) && |
| 3393 | | | (p_val->transaction_state == request_seen) && |
| 3394 | | | (strcmp(cseq_method, p_val->method) == 0) && |
| 3395 | | | (strcmp(cseq_method, "ACK") != 0) && |
| 3396 | | | (strcmp(cseq_method, "CANCEL") != 0)) |
| 3397 | | | { |
| 3398 | | | result = p_val->frame_number; |
| 3399 | | | } |
| 3400 | | | |
| 3401 | | | |
| 3402 | | | if ((line_type == STATUS_LINE) && (cseq_number == cseq_to_compare) && |
| 3403 | | | (p_val->transaction_state == final_response_seen) && |
| 3404 | | | (strcmp(cseq_method, p_val->method) == 0) && |
| 3405 | | | (stat_info->response_code >= 200) && |
| 3406 | | | (stat_info->response_code == p_val->response_code)) |
| 3407 | | | { |
| 3408 | | | result = p_val->frame_number; |
| 3409 | | | } |
| 3410 | | | |
| 3411 | | | |
| 3412 | | | p_val->cseq = cseq_number; |
| 3413 | | | |
| 3414 | | | switch (line_type) |
| 3415 | | | { |
| 3416 | | | case REQUEST_LINE: |
| 3417 | | | p_val->transaction_state = request_seen; |
| 3418 | | | if (!result) |
| 3419 | | | { |
| 3420 | | | |
| 3421 | | | p_val->frame_number = pinfo->fd->num; |
| 3422 | | | } |
| 3423 | | | break; |
| 3424 | | | case STATUS_LINE: |
| 3425 | | | if (stat_info->response_code >= 200) |
| 3426 | | | { |
| 3427 | | | p_val->response_code = stat_info->response_code; |
| 3428 | | | p_val->transaction_state = final_response_seen; |
| 3429 | | | if (!result) |
| 3430 | | | { |
| 3431 | | | |
| 3432 | | | p_val->frame_number = pinfo->fd->num; |
| 3433 | | | } |
| 3434 | | | } |
| 3435 | | | else |
| 3436 | | | { |
| 3437 | | | p_val->transaction_state = provisional_response_seen; |
| 3438 | | | } |
| 3439 | | | break; |
| 3440 | | | default: |
| 3441 | | | break; |
| 3442 | | | } |
| 3443 | | | |
| 3444 | | | sip_frame_result = p_get_proto_data(pinfo->fd, proto_sip); |
| 3445 | | | if (sip_frame_result == NULL) |
| 3446 | | | { |
| 3447 | | | sip_frame_result = se_alloc(sizeof(sip_frame_result_value)); |
| 3448 | | | } |
| 3449 | | | |
| 3450 | | | |
| 3451 | | | sip_frame_result->original_frame_num = result; |
| 3452 | | | p_add_proto_data(pinfo->fd, proto_sip, sip_frame_result); |
| 3453 | | | |
| 3454 | | | return result; |
| 3455 | | | } |
| |