Wireshark-commits: [Wireshark-commits] master-2.0 a7c68da: cops: try to avoid uninitialized warning
From: Wireshark code review <code-review-do-not-reply@xxxxxxxxxxxxx>
Date: Thu, 8 Dec 2016 20:39:53 +0000 (UTC)
URL: https://code.wireshark.org/review/gitweb?p=wireshark.git;a=commit;h=a7c68da099fb431525462145f09190de7ca12989
Submitter: Guy Harris (guy@xxxxxxxxxxxx)
Changed: branch: master-2.0
Repository: wireshark

Commits:

a7c68da by Peter Wu (peter@xxxxxxxxxxxxx):

    cops: try to avoid uninitialized warning error
    
    Valgrind 3.11.0 on the Ubuntu 16.04 buildbot reports that
    cops_call->solicited is not initialized:
    
        pdus_array = (GPtrArray *)wmem_map_lookup(cops_conv_info->pdus_tree, GUINT_TO_POINTER(handle_value));
        /* ... */
        for (i=0; i < pdus_array->len; i++) {
            cops_call = (cops_call_t*)g_ptr_array_index(pdus_array, i);
            if ( /* ... */
            ( (cops_call->op_code == COPS_MSG_KA && !(cops_call->solicited)) &&
                                                      ^^^^^^^^^^^^^^^^^^^^
    
    which is clearly bogus since the only place where cops_call could be
    created is a few lines up:
    
        ver_flags = tvb_get_guint8(tvb, offset);
        is_solicited = (lo_nibble(ver_flags) == 0x01);
        /* ... */
        pdus_array = (GPtrArray *)wmem_map_lookup(cops_conv_info->pdus_tree, GUINT_TO_POINTER(handle_value));
        if (pdus_array == NULL) {
            pdus_array = g_ptr_array_new();
            wmem_map_insert(cops_conv_info->pdus_tree, GUINT_TO_POINTER(handle_value), pdus_array);
        }
        /* ... */
        cops_call = wmem_new(wmem_file_scope(), cops_call_t);
        cops_call->op_code = op_code;
        cops_call->solicited = is_solicited;
        /* ... */
        g_ptr_array_add(pdus_array, cops_call);
    
    Try to zero the whole structure to avoid this bogus warning.
    
    Change-Id: I1ec4d23e99c987849af580a1c8134610c383e55e
    Ping-Bug: 13044
    Ping-Bug: 13203
    Reviewed-on: https://code.wireshark.org/review/19119
    Reviewed-by: Michael Mann <mmann78@xxxxxxxxxxxx>
    Petri-Dish: Peter Wu <peter@xxxxxxxxxxxxx>
    Tested-by: Petri Dish Buildbot <buildbot-no-reply@xxxxxxxxxxxxx>
    Reviewed-by: Peter Wu <peter@xxxxxxxxxxxxx>
    (cherry picked from commit 47829b9611b613425aa0a314224863b02b915ea2)
    Reviewed-on: https://code.wireshark.org/review/19151
    Reviewed-by: Guy Harris <guy@xxxxxxxxxxxx>
    

Actions performed:

    from  2db54cf   RTCP: Bugfix MS Video Source Request dissection
    adds  a7c68da   cops: try to avoid uninitialized warning error


Summary of changes:
 epan/dissectors/packet-cops.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)