Rewrote some prohibited APIs in gtk/ (sprintf, strcpy, strcat).

If we get some truncated strings we probably overwrote some buffers...

svn path=/trunk/; revision=24239
This commit is contained in:
Stig Bjørlykke 2008-02-01 01:07:58 +00:00
parent ee8b8b0ad7
commit 10a8f59e03
20 changed files with 88 additions and 81 deletions

View File

@ -739,9 +739,9 @@ airpcap_update_channel_offset_combo_entry(GtkWidget* w, gchar extChannel)
gchar channel_offset_value[3];
if (extChannel > 0){
sprintf(channel_offset_value, "+%d", extChannel);
g_snprintf(channel_offset_value, 3, "+%d", extChannel);
}else{
sprintf(channel_offset_value, "%d", extChannel);
g_snprintf(channel_offset_value, 3, "%d", extChannel);
}
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(w)->entry), channel_offset_value);

View File

@ -1166,9 +1166,10 @@ capture_if_details_802_11_bssid_list(GtkWidget *main_vb, struct ndis_bssid_list
/* Vendor */
manuf_name = get_manuf_name_if_known(mac);
if(manuf_name != NULL) {
strcpy(vendor_buff, manuf_name);
strncpy(vendor_buff, manuf_name, DETAILS_STR_MAX);
vendor_buff[DETAILS_STR_MAX-1] = '\0';
} else {
strcpy(vendor_buff, "");
vendor_buff[0] = '\0';
}
/* Supported Rates */

View File

@ -759,8 +759,8 @@ ifopts_write_new_descr(void)
tmp_descr = g_strdup_printf("%s(%s)", ifnm, desc);
else
tmp_descr = g_strdup_printf(",%s(%s)", ifnm, desc);
strcat(new_descr, tmp_descr);
g_free(tmp_descr);
strncat(new_descr, tmp_descr, MAX_VAL_LEN - strlen(new_descr));
g_free(tmp_descr);
/* set first-in-list flag to false */
first_if = FALSE;
}
@ -815,8 +815,8 @@ ifopts_write_new_hide(void)
else
tmp_hide = g_strdup_printf(",%s", ifnm);
strcat(new_hide, tmp_hide);
g_free(tmp_hide);
strncat(new_hide, tmp_hide, MAX_VAL_LEN - strlen(new_hide));
g_free(tmp_hide);
/* set first-in-list flag to false */
first_if = FALSE;
}

View File

@ -680,9 +680,9 @@ value_list_sel_cb(GtkTreeSelection *sel, gpointer value_entry_arg)
* testing for "false".
*/
if (value != NULL)
strcpy(value_string, "1");
strncpy(value_string, "1", 2);
else
strcpy(value_string, "0");
strncpy(value_string, "0", 2);
} else {
/*
* Numeric type; get the value corresponding to the

View File

@ -348,10 +348,10 @@ static int flow_graph_tcp_add_to_graph(packet_info *pinfo, const struct tcpheade
bpos = 1 << i;
if (tcph->th_flags & bpos) {
if (fpos) {
strcpy(&flags[fpos], ", ");
strncpy(&flags[fpos], ", ", 64 - fpos - 1);
fpos += 2;
}
strcpy(&flags[fpos], fstr[i]);
strncpy(&flags[fpos], fstr[i], 64 - fpos - 1);
fpos += 3;
}
}

View File

@ -650,7 +650,8 @@ set_app_font_gtk2(const char *fontname)
pfont = pango_context_load_font(pc, pfd);
if (pfont != NULL) {
strcpy(appfontname, fontname);
strncpy(appfontname, fontname, 128);
appfontname[127] = '\0';
g_object_set(G_OBJECT(settings), "gtk-font-name", appfontname, NULL);
}

View File

@ -1056,7 +1056,7 @@ enable_graph(io_stat_graph_t *gio, const char *filter, const char *field)
}
if(*field){
if(real_filter[0]!=0){
strcat(real_filter, " && ");
strncat(real_filter, " && ", 261-strlen(real_filter));
}
strncat(real_filter, field, 261-strlen(real_filter));
real_filter[261]=0;
@ -1424,7 +1424,7 @@ create_yscale_max_menu_items(io_stat_t *io, GtkWidget *menu)
for(i=0;i<MAX_YSCALE;i++){
if(yscale_max[i]==AUTO_MAX_YSCALE){
strcpy(str,"Auto");
strncpy(str, "Auto", 15);
} else {
g_snprintf(str, 15, "%u", yscale_max[i]);
}

View File

@ -859,7 +859,7 @@ tree_view_selection_changed_cb(GtkTreeSelection *sel, gpointer user_data _U_)
if (finfo_length == 0) {
len_str[0] = '\0';
} else if (finfo_length == 1) {
strcpy (len_str, ", 1 byte");
strncpy (len_str, ", 1 byte", sizeof len_str);
} else {
g_snprintf (len_str, sizeof len_str, ", %d bytes", finfo_length);
}

View File

@ -126,7 +126,7 @@ static void add_to_clist(mcast_stream_info_t* strinfo)
gtk_clist_set_row_data(GTK_CLIST(clist), added_row, strinfo);
/* Update the top label with the number of detected streams */
sprintf(label_text,
g_snprintf(label_text, 256,
"Detected %d Multicast streams, Average Bw: %.1f Mbps Max Bw: %.1f Mbps Max burst: %d / %dms Max buffer: %.1f KB",
++streams_nb,
mcaststream_get_info()->allstreams->average_bw, mcaststream_get_info()->allstreams->element.maxbw,
@ -187,10 +187,10 @@ mcaststream_on_filter (GtkButton *button _U_,
if (selected_stream_fwd)
{
if (selected_stream_fwd->src_addr.type==AT_IPv6){
strcpy(ip_version,"v6");
strncpy(ip_version,"v6",3);
}
else{
strcpy(ip_version,"");
strncpy(ip_version,"",3);
}
filter_string_fwd = g_strdup_printf(
"(ip%s.src==%s && udp.srcport==%u && ip%s.dst==%s && udp.dstport==%u)",

View File

@ -1323,7 +1323,7 @@ register_stat_menu_item(
*/
menupathlen = strlen(toolspath) + 1 + (p - name);
menupath = g_malloc(menupathlen);
strcpy(menupath, toolspath);
strncpy(menupath, toolspath, strlen(toolspath) + 1);
strncat(menupath, name, p - name);
/*
@ -1362,8 +1362,8 @@ register_stat_menu_item(
*/
menupathlen = strlen(toolspath) + 1 + strlen(name);
menupath = g_malloc(menupathlen);
strcpy(menupath, toolspath);
strcat(menupath, name);
strncpy(menupath, toolspath, strlen(toolspath) + 1);
strncat(menupath, name, strlen(name) + 1);
/*
* Construct an item factory entry for the item, and add it to

View File

@ -128,8 +128,8 @@ void new_window_cb(GtkWidget *w _U_)
for (i = 0; i < cfile.cinfo.num_cols; ++i) {
TextPtr = cfile.cinfo.col_data[i];
if ((strlen(Title) + strlen(TextPtr)) < NewWinTitleLen - 1) {
strcat(Title, TextPtr);
strcat(Title, " ");
strncat(Title, TextPtr, NewWinTitleLen - 1);
strncat(Title, " ", 2);
}
}

View File

@ -153,14 +153,14 @@ pref_show(pref_t *pref, gpointer user_data)
and left-align it. */
title = pref->title;
label_string = g_malloc(strlen(title) + 2);
strcpy(label_string, title);
strncpy(label_string, title, strlen(title) + 1);
/*
* Sometimes we don't want to append a ':' after a static text string...
* If it is needed, we will specify it in the string itself.
*/
if(pref->type != PREF_STATIC_TEXT)
strcat(label_string, ":");
strncat(label_string, ":", 2);
/* Save the current value of the preference, so that we can revert it if
the user does "Apply" and then "Cancel", and create the control for
@ -303,7 +303,7 @@ module_prefs_show(module_t *module, gpointer user_data)
/*
* Add this module to the tree.
*/
strcpy(label_str, module->title);
strncpy(label_str, module->title, MAX_TREE_NODE_NAME_LEN);
#if GTK_MAJOR_VERSION < 2
ct_node = gtk_ctree_insert_node(GTK_CTREE(cts->tree), cts->node, NULL,
&label_ptr, 5, NULL, NULL, NULL, NULL, !prefs_module_has_submodules(module),
@ -571,30 +571,30 @@ prefs_cb(GtkWidget *w _U_, gpointer dummy _U_)
cts.page = 0;
/* Blank Page */
strcpy(label_str, "(No Specific Preferences)");
strncpy(label_str, "(No Specific Preferences)", MAX_TREE_NODE_NAME_LEN);
prefs_nb_page_add(prefs_nb, label_str, NULL, NULL);
blank_page = cts.page++;
/* GUI prefs */
strcpy(label_str, "User Interface");
strncpy(label_str, "User Interface", MAX_TREE_NODE_NAME_LEN);
prefs_nb_page_add(prefs_nb, label_str, gui_prefs_show(), E_GUI_PAGE_KEY);
gui_iter = prefs_tree_page_add(label_str, cts.page, store, NULL, TRUE);
cts.page++;
/* GUI layout prefs */
strcpy(label_str, "Layout");
strncpy(label_str, "Layout", MAX_TREE_NODE_NAME_LEN);
prefs_nb_page_add(prefs_nb, label_str, layout_prefs_show(), E_GUI_LAYOUT_PAGE_KEY);
prefs_tree_page_add(label_str, cts.page, store, &gui_iter, FALSE);
cts.page++;
/* GUI Column prefs */
strcpy(label_str, "Columns");
strncpy(label_str, "Columns", MAX_TREE_NODE_NAME_LEN);
prefs_nb_page_add(prefs_nb, label_str, column_prefs_show(), E_GUI_COLUMN_PAGE_KEY);
prefs_tree_page_add(label_str, cts.page, store, &gui_iter, FALSE);
cts.page++;
/* GUI Font prefs */
strcpy(label_str, "Font");
strncpy(label_str, "Font", MAX_TREE_NODE_NAME_LEN);
gui_font_pg = gui_font_prefs_show();
prefs_nb_page_add(prefs_nb, label_str, gui_font_pg, E_GUI_FONT_PAGE_KEY);
prefs_tree_page_add(label_str, cts.page, store, &gui_iter, FALSE);
@ -634,7 +634,7 @@ prefs_cb(GtkWidget *w _U_, gpointer dummy _U_)
#endif
/* GUI Colors prefs */
strcpy(label_str, "Colors");
strncpy(label_str, "Colors", MAX_TREE_NODE_NAME_LEN);
prefs_nb_page_add(prefs_nb, label_str, stream_prefs_show(), E_GUI_COLORS_PAGE_KEY);
prefs_tree_page_add(label_str, cts.page, store, &gui_iter, FALSE);
cts.page++;
@ -654,7 +654,7 @@ prefs_cb(GtkWidget *w _U_, gpointer dummy _U_)
if (has_wpcap) {
#endif /* _WIN32 */
/* capture prefs */
strcpy(label_str, "Capture");
strncpy(label_str, "Capture", MAX_TREE_NODE_NAME_LEN);
prefs_nb_page_add(prefs_nb, label_str, capture_prefs_show(), E_CAPTURE_PAGE_KEY);
prefs_tree_page_add(label_str, cts.page, store, NULL, FALSE);
cts.page++;
@ -664,13 +664,13 @@ prefs_cb(GtkWidget *w _U_, gpointer dummy _U_)
#endif /* HAVE_LIBPCAP */
/* Printing prefs */
strcpy(label_str, "Printing");
strncpy(label_str, "Printing", MAX_TREE_NODE_NAME_LEN);
prefs_nb_page_add(prefs_nb, label_str, printer_prefs_show(), E_PRINT_PAGE_KEY);
prefs_tree_page_add(label_str, cts.page, store, NULL, FALSE);
cts.page++;
/* Name resolution prefs */
strcpy(label_str, "Name Resolution");
strncpy(label_str, "Name Resolution", MAX_TREE_NODE_NAME_LEN);
prefs_nb_page_add(prefs_nb, label_str, nameres_prefs_show(), E_NAMERES_PAGE_KEY);
prefs_tree_page_add(label_str, cts.page, store, NULL, FALSE);
cts.page++;
@ -678,7 +678,7 @@ prefs_cb(GtkWidget *w _U_, gpointer dummy _U_)
#ifdef HAVE_LIBPORTAUDIO
#if GTK_MAJOR_VERSION >= 2
/* RTP player prefs */
strcpy(label_str, "RTP Player");
strncpy(label_str, "RTP Player", MAX_TREE_NODE_NAME_LEN);
prefs_nb_page_add(prefs_nb, label_str, rtp_player_prefs_show(), E_RTP_PLAYER_PAGE_KEY);
prefs_tree_page_add(label_str, cts.page, store, NULL, FALSE);
cts.page++;

View File

@ -96,7 +96,7 @@ create_progress_dlg(const gchar *task_title, const gchar *item_title,
/* limit the item_title to some reasonable length */
item_title_dup = g_strdup(item_title);
if (strlen(item_title_dup) > 110) {
strcpy(&item_title_dup[100], "...");
strncpy(&item_title_dup[100], "...", 4);
}
dlg->title = g_strdup_printf("%s: %s", task_title, item_title_dup);

View File

@ -1549,7 +1549,7 @@ static void dialog_graph_draw(user_data_t* user_data)
* Draw "x" for Sequence Errors and "m" for Marks
*/
/* Draw the labels Fwd and Rev */
strcpy(label_string,"<-Fwd");
strncpy(label_string,"<-Fwd",15);
#if GTK_MAJOR_VERSION < 2
lwidth=gdk_string_width(font, label_string);
gdk_draw_string(user_data->dlg.dialog_graph.pixmap,
@ -1567,7 +1567,7 @@ static void dialog_graph_draw(user_data_t* user_data)
user_data->dlg.dialog_graph.pixmap_height-bottom_y_border+3,
layout);
#endif
strcpy(label_string,"<-Rev");
strncpy(label_string,"<-Rev",15);
#if GTK_MAJOR_VERSION < 2
lwidth=gdk_string_width(font, label_string);
gdk_draw_string(user_data->dlg.dialog_graph.pixmap,
@ -1604,9 +1604,9 @@ static void dialog_graph_draw(user_data_t* user_data)
if(user_data->dlg.dialog_graph.graph[i].items[interval/user_data->dlg.dialog_graph.interval].flags & (STAT_FLAG_WRONG_SEQ|STAT_FLAG_MARKER)){
int lwidth;
if (user_data->dlg.dialog_graph.graph[i].items[interval/user_data->dlg.dialog_graph.interval].flags & STAT_FLAG_WRONG_SEQ){
strcpy(label_string,"x");
strncpy(label_string,"x",15);
} else {
strcpy(label_string,"m");
strncpy(label_string,"m",15);
}
#if GTK_MAJOR_VERSION < 2
@ -1991,7 +1991,7 @@ static void create_yscale_max_menu_items(user_data_t* user_data, GtkWidget *menu
for(i=0;i<MAX_YSCALE;i++){
if(yscale_max[i]==AUTO_MAX_YSCALE){
strcpy(str,"Auto");
strncpy(str,"Auto",15);
} else {
g_snprintf(str, 15, "%u ms", yscale_max[i]/1000);
}
@ -3418,16 +3418,20 @@ static void create_rtp_dialog(user_data_t* user_data)
gtk_widget_show(main_vb);
/* Notebooks... */
strcpy(str_ip_src, get_addr_name(&(user_data->ip_src_fwd)));
strcpy(str_ip_dst, get_addr_name(&(user_data->ip_dst_fwd)));
strncpy(str_ip_src, get_addr_name(&(user_data->ip_src_fwd)), 16);
str_ip_src[15] = '\0';
strncpy(str_ip_dst, get_addr_name(&(user_data->ip_dst_fwd)), 16);
str_ip_dst[15] = '\0';
g_snprintf(label_forward, 149,
"Analysing stream from %s port %u to %s port %u SSRC = 0x%X",
str_ip_src, user_data->port_src_fwd, str_ip_dst, user_data->port_dst_fwd, user_data->ssrc_fwd);
strcpy(str_ip_src, get_addr_name(&(user_data->ip_src_rev)));
strcpy(str_ip_dst, get_addr_name(&(user_data->ip_dst_rev)));
strncpy(str_ip_src, get_addr_name(&(user_data->ip_src_rev)), 16);
str_ip_src[15] = '\0';
strncpy(str_ip_dst, get_addr_name(&(user_data->ip_dst_rev)), 16);
str_ip_dst[15] = '\0';
g_snprintf(label_reverse, 149,
"Analysing stream from %s port %u to %s port %u SSRC = 0x%X",
@ -3768,7 +3772,7 @@ static void rtp_analysis_cb(GtkWidget *w _U_, gpointer data _U_)
guint nfound;
/* Try to compile the filter. */
strcpy(filter_text,"rtp && rtp.version && rtp.ssrc && (ip || ipv6)");
strncpy(filter_text,"rtp && rtp.version && rtp.ssrc && (ip || ipv6)",256);
if (!dfilter_compile(filter_text, &sfcode)) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, dfilter_error_msg);
return;

View File

@ -144,7 +144,7 @@ static void add_to_clist(rtp_stream_info_t* strinfo)
gtk_clist_set_row_data(GTK_CLIST(clist), added_row, strinfo);
/* Update the top label with the number of detected streams */
sprintf(label_text,
g_snprintf(label_text, 256,
"Detected %d RTP streams. Choose one for forward and reverse direction for analysis",
++streams_nb);
gtk_label_set(GTK_LABEL(top_label), label_text);
@ -375,10 +375,10 @@ rtpstream_on_filter (GtkButton *button _U_,
if (selected_stream_fwd)
{
if (selected_stream_fwd->src_addr.type==AT_IPv6){
strcpy(ip_version,"v6");
strncpy(ip_version,"v6",3);
}
else{
strcpy(ip_version,"");
strncpy(ip_version,"",3);
}
filter_string_fwd = g_strdup_printf(
"(ip%s.src==%s && udp.srcport==%u && ip%s.dst==%s && udp.dstport==%u && rtp.ssrc==0x%X)",
@ -395,10 +395,10 @@ rtpstream_on_filter (GtkButton *button _U_,
if (selected_stream_rev)
{
if (selected_stream_fwd->src_addr.type==AT_IPv6){
strcpy(ip_version,"v6");
strncpy(ip_version,"v6",3);
}
else{
strcpy(ip_version,"");
strncpy(ip_version,"",3);
}
filter_string_rev = g_strdup_printf(
"(ip%s.src==%s && udp.srcport==%u && ip%s.dst==%s && udp.dstport==%u && rtp.ssrc==0x%X)",

View File

@ -834,7 +834,7 @@ static void sctp_analyse_cb(struct sctp_analyse* u_data, gboolean ext)
int i;
guint32 *fn;
strcpy(filter_text,"sctp");
strncpy(filter_text,"sctp",250);
if (!dfilter_compile(filter_text, &sfcode)) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, dfilter_error_msg);
return;

View File

@ -551,7 +551,7 @@ static void sctp_graph_draw(struct sctp_udata *u_data)
}
}
strcpy(label_string, "sec");
strncpy(label_string, "sec", 15);
#if GTK_MAJOR_VERSION < 2
lwidth = gdk_string_width(font, label_string);

View File

@ -610,7 +610,7 @@ static void sctp_graph_draw(struct sctp_udata *u_data)
}
strcpy(label_string, "sec");
strncpy(label_string, "sec", 15);
#if GTK_MAJOR_VERSION < 2
lwidth=gdk_string_width(font, label_string);

View File

@ -264,7 +264,7 @@ static sctp_assoc_info_t *calc_checksum(struct _sctp_info *check_data, sctp_asso
{
if ((float)(data->n_adler32_correct*1.0/data->n_adler32_calculated) > 0.5)
{
strcpy(data->checksum_type,"ADLER32");
strncpy(data->checksum_type,"ADLER32",8);
data->n_checksum_errors=(data->n_adler32_calculated-data->n_adler32_correct);
ok = TRUE;
}
@ -274,7 +274,7 @@ static sctp_assoc_info_t *calc_checksum(struct _sctp_info *check_data, sctp_asso
{
if ((float)(data->n_crc32c_correct*1.0/data->n_crc32c_calculated) > 0.5)
{
strcpy(data->checksum_type,"CRC32C");
strncpy(data->checksum_type,"CRC32C",8);
data->n_checksum_errors=data->n_crc32c_calculated-data->n_crc32c_correct;
ok = TRUE;
}
@ -282,7 +282,7 @@ static sctp_assoc_info_t *calc_checksum(struct _sctp_info *check_data, sctp_asso
if (!ok)
{
strcpy(data->checksum_type,"UNKNOWN");
strncpy(data->checksum_type,"UNKNOWN",8);
data->n_checksum_errors=0;
}
@ -883,13 +883,14 @@ packet(void *tapdata _U_, packet_info *pinfo , epan_dissect_t *edt _U_ , const v
{
error = g_malloc(sizeof(sctp_error_info_t));
error->frame_number = pinfo->fd->num;
strcpy(str,"");
strcpy(error->chunk_info,"");
str[0] = '\0';
error->chunk_info[0] = '\0';
if ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_INIT_CHUNK_ID)
strcpy(error->chunk_info, val_to_str(tvb_get_guint8(sctp_info->tvb[0],0),chunk_type_values,"Reserved"));
strncpy(error->chunk_info, val_to_str(tvb_get_guint8(sctp_info->tvb[0],0),chunk_type_values,"Reserved"), 200);
else
for (chunk_number = 0; chunk_number < sctp_info->number_of_tvbs; chunk_number++)
strcat(error->chunk_info, val_to_str(tvb_get_guint8(sctp_info->tvb[chunk_number],0),chunk_type_values,"Reserved"));
strncat(error->chunk_info, val_to_str(tvb_get_guint8(sctp_info->tvb[chunk_number],0),chunk_type_values,"Reserved"), 200 - strlen (error->chunk_info));
error->chunk_info[199] = '\0';
error->info_text = "INFOS";
info->error_info_list = g_list_append(info->error_info_list, error);
}

View File

@ -279,7 +279,7 @@ summary_open_cb(GtkWidget *w _U_, gpointer d _U_)
if (summary.dfilter) {
g_snprintf(string_buff2, SUM_STR_MAX, "%i", summary.filtered_count);
} else {
strcpy(string_buff2, string_buff);
strncpy(string_buff2, string_buff, SUM_STR_MAX);
}
g_snprintf(string_buff3, SUM_STR_MAX, "%i", summary.marked_count);
add_string_to_list(list, "Packets", string_buff, string_buff2, string_buff3);
@ -288,17 +288,17 @@ summary_open_cb(GtkWidget *w _U_, gpointer d _U_)
if (seconds > 0) {
g_snprintf(string_buff, SUM_STR_MAX, "%.3f sec", seconds);
} else {
strcpy(string_buff, "");
strncpy(string_buff, "", SUM_STR_MAX);
}
if (summary.dfilter && disp_seconds > 0) {
g_snprintf(string_buff2, SUM_STR_MAX, "%.3f sec", disp_seconds);
} else {
strcpy(string_buff2, "");
strncpy(string_buff2, "", SUM_STR_MAX);
}
if (summary.marked_count && marked_seconds > 0) {
g_snprintf(string_buff3, SUM_STR_MAX, "%.3f sec", marked_seconds);
} else {
strcpy(string_buff3, "");
strncpy(string_buff3, "", SUM_STR_MAX);
}
add_string_to_list(list, "Between first and last packet", string_buff, string_buff2, string_buff3);
@ -306,17 +306,17 @@ summary_open_cb(GtkWidget *w _U_, gpointer d _U_)
if (seconds > 0) {
g_snprintf(string_buff, SUM_STR_MAX, "%.3f", summary.packet_count/seconds);
} else {
strcpy(string_buff, "");
strncpy(string_buff, "", SUM_STR_MAX);
}
if(summary.dfilter && disp_seconds > 0) {
g_snprintf(string_buff2, SUM_STR_MAX, "%.3f", summary.filtered_count/disp_seconds);
} else {
strcpy(string_buff2, "");
strncpy(string_buff2, "", SUM_STR_MAX);
}
if(summary.marked_count && marked_seconds > 0) {
g_snprintf(string_buff3, SUM_STR_MAX, "%.3f", summary.marked_count/marked_seconds);
} else {
strcpy(string_buff3, "");
strncpy(string_buff3, "", SUM_STR_MAX);
}
add_string_to_list(list, "Avg. packets/sec", string_buff, string_buff2, string_buff3);
@ -326,21 +326,21 @@ summary_open_cb(GtkWidget *w _U_, gpointer d _U_)
/* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
(float) ((gint64) summary.bytes)/summary.packet_count);
} else {
strcpy(string_buff, "");
strncpy(string_buff, "", SUM_STR_MAX);
}
if (summary.dfilter && summary.filtered_count > 1) {
g_snprintf(string_buff2, SUM_STR_MAX, "%.3f bytes",
/* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
(float) ((gint64) summary.filtered_bytes)/summary.filtered_count);
} else {
strcpy(string_buff2, "");
strncpy(string_buff2, "", SUM_STR_MAX);
}
if (summary.marked_count > 1) {
g_snprintf(string_buff3, SUM_STR_MAX, "%.3f bytes",
/* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
(float) ((gint64) summary.marked_bytes)/summary.marked_count);
} else {
strcpy(string_buff3, "");
strncpy(string_buff3, "", SUM_STR_MAX);
}
add_string_to_list(list, "Avg. packet size", string_buff, string_buff2, string_buff3);
@ -349,12 +349,12 @@ summary_open_cb(GtkWidget *w _U_, gpointer d _U_)
if (summary.dfilter && summary.filtered_count > 0) {
g_snprintf(string_buff2, SUM_STR_MAX, "%" G_GINT64_MODIFIER "u", summary.filtered_bytes);
} else {
strcpy(string_buff2, "");
strncpy(string_buff2, "", SUM_STR_MAX);
}
if (summary.marked_count) {
g_snprintf(string_buff3, SUM_STR_MAX, "%" G_GINT64_MODIFIER "u", summary.marked_bytes);
} else {
strcpy(string_buff3, "");
strncpy(string_buff3, "", SUM_STR_MAX);
}
add_string_to_list(list, "Bytes", string_buff, string_buff2, string_buff3);
@ -363,19 +363,19 @@ summary_open_cb(GtkWidget *w _U_, gpointer d _U_)
/* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
g_snprintf(string_buff, SUM_STR_MAX, "%.3f", ((gint64) summary.bytes)/seconds);
} else {
strcpy(string_buff, "");
strncpy(string_buff, "", SUM_STR_MAX);
}
if (summary.dfilter && disp_seconds > 0) {
/* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
g_snprintf(string_buff2, SUM_STR_MAX, "%.3f", ((gint64) summary.filtered_bytes)/disp_seconds);
} else {
strcpy(string_buff2, "");
strncpy(string_buff2, "", SUM_STR_MAX);
}
if (summary.marked_count && marked_seconds > 0) {
/* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
g_snprintf(string_buff3, SUM_STR_MAX, "%.3f", ((gint64) summary.marked_bytes)/marked_seconds);
} else {
strcpy(string_buff3, "");
strncpy(string_buff3, "", SUM_STR_MAX);
}
add_string_to_list(list, "Avg. bytes/sec", string_buff, string_buff2, string_buff3);
@ -385,21 +385,21 @@ summary_open_cb(GtkWidget *w _U_, gpointer d _U_)
/* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
((gint64) summary.bytes) * 8.0 / (seconds * 1000.0 * 1000.0));
} else {
strcpy(string_buff, "");
strncpy(string_buff, "", SUM_STR_MAX);
}
if (summary.dfilter && disp_seconds > 0) {
g_snprintf(string_buff2, SUM_STR_MAX, "%.3f",
/* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
((gint64) summary.filtered_bytes) * 8.0 / (disp_seconds * 1000.0 * 1000.0));
} else {
strcpy(string_buff2, "");
strncpy(string_buff2, "", SUM_STR_MAX);
}
if (summary.marked_count && marked_seconds > 0) {
g_snprintf(string_buff3, SUM_STR_MAX, "%.3f",
/* MSVC cannot convert from unsigned __int64 to float, so first convert to signed __int64 */
((gint64) summary.marked_bytes) * 8.0 / (marked_seconds * 1000.0 * 1000.0));
} else {
strcpy(string_buff3, "");
strncpy(string_buff3, "", SUM_STR_MAX);
}
add_string_to_list(list, "Avg. MBit/sec", string_buff, string_buff2, string_buff3);