(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-ber.c) |
| |
| 3650 | | | dissect_ber_GeneralizedTime(gboolean implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_id) |
| 3651 | | | { |
| 3652 | | | char str[35]; |
| 3653 | | | const guint8 *tmpstr; |
| 3654 | | | char *strptr; |
| 3655 | | | char first_delim[2]; |
| 3656 | | | int first_digits; |
| 3657 | | | char second_delim[2]; |
| 3658 | | | int second_digits; |
| 3659 | | | gint8 class; |
| 3660 | | | gboolean pc; |
| 3661 | | | gint32 tag; |
| 3662 | | | guint32 len; |
| 3663 | | | int end_offset; |
| 3664 | | | int hoffset; |
| 3665 | | | proto_item *cause; |
| 3666 | | | |
| 3667 | | | if(!implicit_tag){ |
| 3668 | | | hoffset = offset; |
| 3669 | | | offset=dissect_ber_identifier(actx->pinfo, tree, tvb, offset, &class, &pc, &tag); |
| 3670 | | | offset=dissect_ber_length(actx->pinfo, tree, tvb, offset, &len, NULL); |
| 3671 | | | end_offset=offset+len; |
| 3672 | | | |
| 3673 | | | |
| 3674 | | | if( (class!=BER_CLASS_UNI) |
| 3675 | | | ||(tag!=BER_UNI_TAG_GeneralizedTime)){ |
| 3676 | | | tvb_ensure_bytes_exist(tvb, hoffset, 2); |
| 3677 | | | cause = proto_tree_add_text(tree, tvb, offset, len, "BER Error: GeneralizedTime expected but class:%s(%d) %s tag:%d was unexpected", val_to_str(class,ber_class_codes,"Unknown"), class, pc ? ber_pc_codes_short.true_string : ber_pc_codes_short.false_string, tag); |
| 3678 | | | proto_item_set_expert_flags(cause, PI_MALFORMED, PI_WARN); |
| 3679 | | | expert_add_info_format(actx->pinfo, cause, PI_MALFORMED, PI_WARN, "BER Error: GeneralizedTime expected"); |
| 3680 | | | if (decode_unexpected) { |
| 3681 | | | proto_tree *unknown_tree = proto_item_add_subtree(cause, ett_ber_unknown); |
| 3682 | | | dissect_unknown_ber(actx->pinfo, tvb, hoffset, unknown_tree); |
| 3683 | | | } |
| 3684 | | | return end_offset; |
| 3685 | | | } |
| 3686 | | | } else { |
| 3687 | | | len=tvb_length_remaining(tvb,offset); |
| 3688 | | | end_offset=offset+len; |
| 3689 | | | } |
| 3690 | | | |
| 3691 | | | tmpstr=tvb_get_ptr(tvb, offset, len); |
| 3692 | | | strptr = str; |
| 3693 | | | |
| 3694 | | | strptr += g_snprintf(str, 20, "%.4s-%.2s-%.2s %.2s:%.2s:%.2s", |
| 3695 | | | tmpstr, tmpstr+4, tmpstr+6, tmpstr+8, |
| 3696 | | | tmpstr+10, tmpstr+12); |
| 3697 | | | |
| 3698 | | | first_delim[0]=0; |
| 3699 | | | second_delim[0]=0; |
| 3700 | | | sscanf( tmpstr, "%*14d%1[.,+-Z]%4d%1[+-Z]%4d", first_delim, &first_digits, second_delim, &second_digits); |
Ignored Return Value
The return value of __isoc99_sscanf() 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.
- CodeSonar is configured to enforce Ignored Return Value checks for __isoc99_sscanf(). (To change the set of enforced Ignored Return Value checks, use configuration file parameters RETURN_CHECKER_CHECKED_FUNCS and RETURN_CHECKER_IGNORED_FUNCS).
Show: All events | Only primary events |
|
| 3701 | | | |
| 3702 | | | switch (first_delim[0]) { |
Event 2:
first_delim[0] evaluates to 46.
hide
|
|
| 3703 | | | case '.': |
| 3704 | | | case ',': |
| 3705 | | | strptr += g_snprintf(strptr, 5, "%c%.3d", first_delim[0], first_digits); |
| 3706 | | | switch (second_delim[0]) { |
Event 3:
second_delim[0] evaluates to 90.
hide
|
|
| 3707 | | | case '+': |
| 3708 | | | case '-': |
| 3709 | | | g_snprintf(strptr, 12, " (UTC%c%.4d)", second_delim[0], second_digits); |
| 3710 | | | break; |
| 3711 | | | case 'Z': |
| 3712 | | | g_snprintf(strptr, 7, " (UTC)"); |
| 3713 | | | break; |
| 3714 | | | case 0: |
| 3715 | | | break; |
| 3716 | | | default: |
| 3717 | | | |
| 3718 | | | break; |
| 3719 | | | } |
| 3720 | | | break; |
| 3721 | | | case '+': |
| 3722 | | | case '-': |
| 3723 | | | g_snprintf(strptr, 12, " (UTC%c%.4d)", first_delim[0], first_digits); |
| 3724 | | | break; |
| 3725 | | | case 'Z': |
| 3726 | | | g_snprintf(strptr, 7, " (UTC)"); |
| 3727 | | | break; |
| 3728 | | | case 0: |
| 3729 | | | break; |
| 3730 | | | default: |
| 3731 | | | |
| 3732 | | | break; |
| 3733 | | | } |
| 3734 | | | |
| 3735 | | | if(hf_id >= 0){ |
Event 4:
Taking true branch. hf_id >= 0 evaluates to true.
hide
|
|
| 3736 | | | proto_tree_add_string(tree, hf_id, tvb, offset, len, str); |
| 3737 | | | } |
| 3738 | | | |
| 3739 | | | offset+=len; |
| 3740 | | | return offset; |
| 3741 | | | } |
| |