summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2015-06-25 02:05:30 +0200
committerAnders Broman <a.broman58@gmail.com>2015-06-25 15:38:45 +0000
commit3f5d183a44cada18eea7969fd8cc60f8e8781b26 (patch)
tree962bb8a20973711a825153734cf20d069b5a5ef4
parentfe6ece9689d54e64e9f1fdc74170da343db16aff (diff)
downloadwireshark-3f5d183a44cada18eea7969fd8cc60f8e8781b26.tar.gz
Stop using atof/strtod (fixes column sorting of float types)
atof is locale-dependent. In locales such as Swedish, German and Dutch, the dot is a thousand separator, resulting in wrong conversions for floats. While at it, make the mate dissector also be independent of locale. Blacklist atof in checkAPIs. Lemon is still using strtod, but that is not our problem for now. Bug: 11297 Bug: 8964 Change-Id: I6fe3e45eb1d6d95d41aa4f3af1f81a6204a60c63 Reviewed-on: https://code.wireshark.org/review/9116 Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Petri-Dish: Gerald Combs <gerald@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rw-r--r--epan/asn1.c2
-rw-r--r--epan/dissectors/packet-catapult-dct2000.c2
-rw-r--r--plugins/mate/mate_grammar.lemon4
-rwxr-xr-xtools/checkAPIs.pl1
-rw-r--r--ui/gtk/hostlist_table.c4
-rw-r--r--ui/gtk/packet_list_store.c4
6 files changed, 9 insertions, 8 deletions
diff --git a/epan/asn1.c b/epan/asn1.c
index caefb08064..7afa107192 100644
--- a/epan/asn1.c
+++ b/epan/asn1.c
@@ -278,7 +278,7 @@ double asn1_get_real(const guint8 *real_ptr, gint len) {
}
} else { /* decimal encoding */
buf = g_strndup(p, len);
- val = atof(buf);
+ val = g_ascii_strtod(buf, NULL);
g_free(buf);
}
diff --git a/epan/dissectors/packet-catapult-dct2000.c b/epan/dissectors/packet-catapult-dct2000.c
index f1fa6f58f5..df8a461b2e 100644
--- a/epan/dissectors/packet-catapult-dct2000.c
+++ b/epan/dissectors/packet-catapult-dct2000.c
@@ -2139,7 +2139,7 @@ dissect_catapult_dct2000(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
displayed as a custom column... */
proto_tree_add_double(dct2000_tree, hf_catapult_dct2000_timestamp, tvb,
offset, timestamp_length,
- atof(timestamp_string));
+ g_ascii_strtod(timestamp_string, NULL));
}
offset += timestamp_length;
diff --git a/plugins/mate/mate_grammar.lemon b/plugins/mate/mate_grammar.lemon
index eea18aa2ae..83e280edbc 100644
--- a/plugins/mate/mate_grammar.lemon
+++ b/plugins/mate/mate_grammar.lemon
@@ -602,11 +602,11 @@ pdu_name(A) ::= NAME(B). {
time_value(A) ::= FLOATING(B). {
- A = (float) strtod(B,NULL);
+ A = (float) g_ascii_strtod(B,NULL);
}
time_value(A) ::= INTEGER(B). {
- A = (float) strtod(B,NULL);
+ A = (float) g_ascii_strtod(B,NULL);
}
/************* GOG
diff --git a/tools/checkAPIs.pl b/tools/checkAPIs.pl
index 7527141817..bc6059fd27 100755
--- a/tools/checkAPIs.pl
+++ b/tools/checkAPIs.pl
@@ -109,6 +109,7 @@ my %APIs = (
'isupper',
'isxdigit',
'tolower',
+ 'atof',
'strtod',
'strcasecmp',
'strncasecmp',
diff --git a/ui/gtk/hostlist_table.c b/ui/gtk/hostlist_table.c
index 7913acc108..39845fa44c 100644
--- a/ui/gtk/hostlist_table.c
+++ b/ui/gtk/hostlist_table.c
@@ -182,12 +182,12 @@ hostlist_sort_column(GtkTreeModel *model,
gtk_tree_model_get(model, b, data_column, &text2, -1);
if (text1) {
- loc1 = atof(text1);
+ loc1 = g_ascii_strtod(text1, NULL);
g_free(text1);
}
if (text2) {
- loc2 = atof(text2);
+ loc2 = g_ascii_strtod(text2, NULL);
g_free(text2);
}
CMP_INT(loc1, loc2);
diff --git a/ui/gtk/packet_list_store.c b/ui/gtk/packet_list_store.c
index cddc2778aa..dbb511ae43 100644
--- a/ui/gtk/packet_list_store.c
+++ b/ui/gtk/packet_list_store.c
@@ -943,8 +943,8 @@ packet_list_compare_custom(gint sort_id, gint text_sort_id, PacketListRecord *a,
(hfi->type == FT_RELATIVE_TIME)))
{
/* Attempt to convert to numbers */
- double num_a = atof(a->col_text[text_sort_id]);
- double num_b = atof(b->col_text[text_sort_id]);
+ double num_a = g_ascii_strtod(a->col_text[text_sort_id], NULL);
+ double num_b = g_ascii_strtod(b->col_text[text_sort_id], NULL);
if (num_a < num_b)
return -1;