Text   |  XML   |  ReML   |   Visible Warnings:

Format String  at packet-artnet.c:827

No properties have been set. | edit properties
Jump to warning location ↓ warning details...
Show Events | Options

dissect_artnet_output

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-artnet.c)expand/collapse
Show more  
 753  dissect_artnet_output(tvbuff_t *tvb, guint offset, proto_tree *tree)
 754  {
 755    proto_tree *hi,*si;
 756    proto_item *item;
 757    guint16 length,r,c,row_count;
 758    guint8 v;
 759    static char string[255];
 760    char* ptr;
 761    const char* chan_format[] = {
 762      "%2u ",
 763      "%02x ",
 764      "%3u "
 765    };
 766    const char* string_format[] = {
 767      "%03x: %s",
 768      "%3u: %s"
 769    };
 770   
 771    proto_tree_add_item(tree, hf_artnet_output_sequence, tvb,
 772                        offset, 1, FALSE);
 773    offset += 1;
 774   
 775    proto_tree_add_item(tree, hf_artnet_output_physical, tvb,
 776                        offset, 1, FALSE);
 777    offset += 1;
 778   
 779    proto_tree_add_item(tree, hf_artnet_output_universe, tvb,
 780                        offset, 2, TRUE);
 781    offset += 2;
 782   
 783    length = tvb_get_ntohs(tvb, offset);
 784    proto_tree_add_uint(tree, hf_artnet_output_length, tvb,
 785                        offset, 2, length);
 786    offset += 2;
 787   
 788    hi = proto_tree_add_item(tree,
 789                             hf_artnet_output_data,
 790                             tvb,
 791                             offset,
 792                             length,
 793                             FALSE);
 794                                                                                                                   
 795    si = proto_item_add_subtree(hi, ett_artnet);
 796   
 797    row_count = (length/global_disp_col_count) + ((length%global_disp_col_count) == 0 ? 0 : 1);
 798    ptr = string;
 799    /* XX: In theory the g_snprintf statements below could store '\0' bytes off the end of the     */
 800    /*     'string' buffer'. This is so since g_snprint returns the number of characters which     */
 801    /*     "would have been written" (whether or not there was room) and since ptr is always       */
 802    /*     incremented by this amount. In practice the string buffer is large enough such that the */
 803    /*     string buffer size is not exceeded even with the maximum number of columns which might  */
 804    /*     be displayed.                                                                           */
 805    /*     ToDo: consider recoding slightly ...                                                    */
 806    for (r=0; r < row_count;r++) {
 807      for (c=0;(c < global_disp_col_count) && (((r*global_disp_col_count)+c) < length);c++) {
 808        if ((c % (global_disp_col_count/2)) == 0) {
 809          ptr += g_snprintf(ptr, (gulong)(sizeof string - strlen(string)), " ");
 810        }
 811   
 812        v = tvb_get_guint8(tvb, (offset+(r*global_disp_col_count)+c));
 813        if (global_disp_chan_val_type == 0) {
 814          v = (v * 100) / 255;
 815          if (v == 100) {
 816            ptr += g_snprintf(ptr, (gulong)(sizeof string - strlen(string)), "FL ");
 817          } else {
 818            ptr += g_snprintf(ptr, (gulong)(sizeof string - strlen(string)), chan_format[global_disp_chan_val_type], v);
 819          }
 820        } else {
 821          ptr += g_snprintf(ptr, (gulong)(sizeof string - strlen(string)), chan_format[global_disp_chan_val_type], v);
 822        }
 823      }
 824       
 825      proto_tree_add_none_format(si,hf_artnet_output_dmx_data, tvb,
 826                                 offset+(r*global_disp_col_count), c,  
 827                                 string_format[global_disp_chan_nr_type], (r*global_disp_col_count)+1, string);
 828      ptr = string;
 829    }
 830   
 831    /* Add the real type hidden */
 832    item = proto_tree_add_item(si, hf_artnet_output_data_filter, tvb,
 833                        offset, length, FALSE );
 834    PROTO_ITEM_SET_HIDDEN(item);
 835    offset += length;
 836   
 837    return offset;
 838  }
Show more  




Change Warning 5567.35875 : Format String

Priority:
State:
Finding:
Owner:
Note: