diff options
author | Gerald Combs <gerald@wireshark.org> | 2016-09-20 14:11:29 -0700 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2016-12-01 01:26:39 +0000 |
commit | cbf89c8ed842a58c282872cf8c42adf9b8b2ffee (patch) | |
tree | 3a0c338486818e511d8b9f27b0d16b3b213bcf9d | |
parent | 9887cd7feb7c377a3d046b924fe86907479be413 (diff) |
Check preference titles and descriptions.
When registering preferences, make sure our titles and descriptions are
valid UTF-8. Make sure our titles are short and only contain printable
characters.
Fix problematic titles and descriptions.
Change-Id: I20d3f93438f2b3c30266f934297feb79897f2ee5
Reviewed-on: https://code.wireshark.org/review/18998
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
-rw-r--r-- | epan/dissectors/asn1/snmp/packet-snmp-template.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-cp2179.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-diameter.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-distcc.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-eth.c | 4 | ||||
-rw-r--r-- | epan/dissectors/packet-ieee80211.c | 19 | ||||
-rw-r--r-- | epan/dissectors/packet-ipv6.c | 4 | ||||
-rw-r--r-- | epan/dissectors/packet-iscsi.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-rpc.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-rtsp.c | 3 | ||||
-rw-r--r-- | epan/dissectors/packet-smtp.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-snmp.c | 2 | ||||
-rw-r--r-- | epan/prefs.c | 39 | ||||
-rw-r--r-- | epan/prefs.h | 10 |
14 files changed, 63 insertions, 32 deletions
diff --git a/epan/dissectors/asn1/snmp/packet-snmp-template.c b/epan/dissectors/asn1/snmp/packet-snmp-template.c index 90d0a3aebe..7e4ade2470 100644 --- a/epan/dissectors/asn1/snmp/packet-snmp-template.c +++ b/epan/dissectors/asn1/snmp/packet-snmp-template.c @@ -2540,7 +2540,7 @@ void proto_register_snmp(void) { prefs_register_obsolete_preference(snmp_module, "users_file"); prefs_register_bool_preference(snmp_module, "desegment", - "Reassemble SNMP-over-TCP messages\nspanning multiple TCP segments", + "Reassemble SNMP-over-TCP messages spanning multiple TCP segments", "Whether the SNMP dissector should reassemble messages spanning multiple TCP segments." " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.", &snmp_desegment); diff --git a/epan/dissectors/packet-cp2179.c b/epan/dissectors/packet-cp2179.c index f43e5a6075..d3d5ae8197 100644 --- a/epan/dissectors/packet-cp2179.c +++ b/epan/dissectors/packet-cp2179.c @@ -1363,7 +1363,7 @@ proto_register_cp2179(void) /* Telnet protocol IAC (0xFF) processing; defaults to TRUE to allow Telnet Encapsulated Data */ prefs_register_bool_preference(cp2179_module, "telnetclean", - "Enable Automatic pre-processing of Telnet-encapsulated data to remove extra 0xFF (IAC) bytes", + "Remove extra 0xFF (IAC) bytes from Telnet-encapsulated data", "Whether the SEL Protocol dissector should automatically pre-process Telnet data to remove IAC bytes", &cp2179_telnet_clean); diff --git a/epan/dissectors/packet-diameter.c b/epan/dissectors/packet-diameter.c index 706bf05bfa..55011ac201 100644 --- a/epan/dissectors/packet-diameter.c +++ b/epan/dissectors/packet-diameter.c @@ -2345,7 +2345,7 @@ proto_register_diameter(void) /* Desegmentation */ prefs_register_bool_preference(diameter_module, "desegment", - "Reassemble Diameter messages\nspanning multiple TCP segments", + "Reassemble Diameter messages spanning multiple TCP segments", "Whether the Diameter dissector should reassemble messages spanning multiple TCP segments." " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.", &gbl_diameter_desegment); diff --git a/epan/dissectors/packet-distcc.c b/epan/dissectors/packet-distcc.c index 44a1ca936b..7903ae5806 100644 --- a/epan/dissectors/packet-distcc.c +++ b/epan/dissectors/packet-distcc.c @@ -367,7 +367,7 @@ proto_register_distcc(void) distcc_module = prefs_register_protocol(proto_distcc, NULL); prefs_register_bool_preference(distcc_module, "desegment_distcc_over_tcp", - "Reassemble DISTCC-over-TCP messages\nspanning multiple TCP segments", + "Reassemble DISTCC-over-TCP messages spanning multiple TCP segments", "Whether the DISTCC dissector should reassemble messages spanning multiple TCP segments." " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.", &distcc_desegment); diff --git a/epan/dissectors/packet-eth.c b/epan/dissectors/packet-eth.c index b07726fb4f..fc834c5759 100644 --- a/epan/dissectors/packet-eth.c +++ b/epan/dissectors/packet-eth.c @@ -965,11 +965,11 @@ proto_register_eth(void) ð_interpret_as_fw1_monitor); prefs_register_static_text_preference(eth_module, "ccsds_heuristic", + "Dissect as CCSDS if", "These are the conditions to match a payload against in order to determine if this\n" "is a CCSDS (Consultative Committee for Space Data Systems) packet within\n" "an 802.3 packet. A packet is considered as a possible CCSDS packet only if\n" - "one or more of the conditions are checked.", - "Describe the conditions that must be true for the CCSDS dissector to be called"); + "one or more of the conditions are checked."); prefs_register_bool_preference(eth_module, "ccsds_heuristic_length", "CCSDS Length in header matches payload size", diff --git a/epan/dissectors/packet-ieee80211.c b/epan/dissectors/packet-ieee80211.c index 5707251f07..f83929328b 100644 --- a/epan/dissectors/packet-ieee80211.c +++ b/epan/dissectors/packet-ieee80211.c @@ -27420,14 +27420,6 @@ proto_register_ieee80211(void) "Enable decryption", "Enable WEP and WPA/WPA2 decryption", &enable_decryption); - prefs_register_static_text_preference(wlan_module, "info_decryption_key", - "Key examples: 01:02:03:04:05 (40/64-bit WEP),\n" - "010203040506070809101111213 (104/128-bit WEP),\n" - "MyPassword[:MyAP] (WPA + plaintext password [+ SSID]),\n" - "0102030405...6061626364 (WPA + 256-bit key). " - "Invalid keys will be ignored.", - "Valid key formats"); - wep_uat = uat_new("WEP and WPA Decryption Keys", sizeof(uat_wep_key_record_t), /* record size */ "80211_keys", /* filename */ @@ -27435,7 +27427,7 @@ proto_register_ieee80211(void) &uat_wep_key_records, /* data_ptr */ &num_wepkeys_uat, /* numitems_ptr */ UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */ - NULL, /* help */ + NULL, /* help. XXX Needs chapter in WSUG */ uat_wep_key_record_copy_cb, /* copy callback */ uat_wep_key_record_update_cb, /* update callback */ uat_wep_key_record_free_cb, /* free callback */ @@ -27444,8 +27436,13 @@ proto_register_ieee80211(void) prefs_register_uat_preference(wlan_module, "wep_key_table", - "Decryption Keys", - "WEP and pre-shared WPA keys", + "Decryption keys", + "WEP and pre-shared WPA keys\n" + "Key examples: 01:02:03:04:05 (40/64-bit WEP),\n" + "010203040506070809101111213 (104/128-bit WEP),\n" + "MyPassword[:MyAP] (WPA + plaintext password [+ SSID]),\n" + "0102030405...6061626364 (WPA + 256-bit key)." + "Invalid keys will be ignored.", wep_uat); } diff --git a/epan/dissectors/packet-ipv6.c b/epan/dissectors/packet-ipv6.c index 922c9f8bd1..c5f603bb3e 100644 --- a/epan/dissectors/packet-ipv6.c +++ b/epan/dissectors/packet-ipv6.c @@ -3501,8 +3501,8 @@ proto_register_ipv6(void) /* RPL Strict Header Checking */ prefs_register_bool_preference(ipv6_module, "perform_strict_rpl_srh_rfc_checking", - "Perform strict checking for adherence to the RFC for RPL Source Routing Headers (RFC 6554)", - "Whether to check that all RPL Source Routed packets do not visit a node more than once", + "Perform strict checking for RPL Source Routing Headers (RFC 6554)", + "Check that all RPL Source Routed packets conform to RFC 6554 and do not visit a node more than once", &g_ipv6_rpl_srh_strict_rfc_checking); prefs_register_bool_preference(ipv6_module, "try_heuristic_first", diff --git a/epan/dissectors/packet-iscsi.c b/epan/dissectors/packet-iscsi.c index fd8e00fbef..f5d44d6f53 100644 --- a/epan/dissectors/packet-iscsi.c +++ b/epan/dissectors/packet-iscsi.c @@ -3107,7 +3107,7 @@ proto_register_iscsi(void) prefs_register_bool_preference(iscsi_module, "desegment_iscsi_messages", - "Reassemble iSCSI messages\nspanning multiple TCP segments", + "Reassemble iSCSI messages spanning multiple TCP segments", "Whether the iSCSI dissector should reassemble messages spanning multiple TCP segments." " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.", &iscsi_desegment); diff --git a/epan/dissectors/packet-rpc.c b/epan/dissectors/packet-rpc.c index e6bd7fa9ca..cac55c1119 100644 --- a/epan/dissectors/packet-rpc.c +++ b/epan/dissectors/packet-rpc.c @@ -4375,7 +4375,7 @@ proto_register_rpc(void) rpc_module = prefs_register_protocol(proto_rpc, NULL); prefs_register_bool_preference(rpc_module, "desegment_rpc_over_tcp", - "Reassemble RPC over TCP messages\nspanning multiple TCP segments", + "Reassemble RPC over TCP messages spanning multiple TCP segments", "Whether the RPC dissector should reassemble messages spanning multiple TCP segments." " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.", &rpc_desegment); diff --git a/epan/dissectors/packet-rtsp.c b/epan/dissectors/packet-rtsp.c index 063251d193..d4f95a8453 100644 --- a/epan/dissectors/packet-rtsp.c +++ b/epan/dissectors/packet-rtsp.c @@ -1489,8 +1489,7 @@ proto_register_rtsp(void) " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.", &rtsp_desegment_headers); prefs_register_bool_preference(rtsp_module, "desegment_body", - "Trust the \"Content-length:\" header and\ndesegment RTSP " - "bodies\nspanning multiple TCP segments", + "Trust the \"Content-length:\" header when desegmenting", "Whether the RTSP dissector should use the " "\"Content-length:\" value to desegment the body " "of a request spanning multiple TCP segments", diff --git a/epan/dissectors/packet-smtp.c b/epan/dissectors/packet-smtp.c index c99c582a14..8b9f367e9e 100644 --- a/epan/dissectors/packet-smtp.c +++ b/epan/dissectors/packet-smtp.c @@ -1292,7 +1292,7 @@ proto_register_smtp(void) /* Preferences */ smtp_module = prefs_register_protocol(proto_smtp, NULL); prefs_register_bool_preference(smtp_module, "desegment_lines", - "Reassemble SMTP command and response lines\nspanning multiple TCP segments", + "Reassemble SMTP command and response lines spanning multiple TCP segments", "Whether the SMTP dissector should reassemble command and response lines" " spanning multiple TCP segments. To use this option, you must also enable " "\"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.", diff --git a/epan/dissectors/packet-snmp.c b/epan/dissectors/packet-snmp.c index e8774b84c8..3d51523d66 100644 --- a/epan/dissectors/packet-snmp.c +++ b/epan/dissectors/packet-snmp.c @@ -4038,7 +4038,7 @@ void proto_register_snmp(void) { prefs_register_obsolete_preference(snmp_module, "users_file"); prefs_register_bool_preference(snmp_module, "desegment", - "Reassemble SNMP-over-TCP messages\nspanning multiple TCP segments", + "Reassemble SNMP-over-TCP messages spanning multiple TCP segments", "Whether the SNMP dissector should reassemble messages spanning multiple TCP segments." " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.", &snmp_desegment); diff --git a/epan/prefs.c b/epan/prefs.c index 43eec4d726..ee227896a1 100644 --- a/epan/prefs.c +++ b/epan/prefs.c @@ -787,6 +787,7 @@ register_preference(module_t *module, const char *name, const char *title, { pref_t *preference; const gchar *p; + const char *name_prefix = (module->name != NULL) ? module->name : module->parent->name; preference = g_new(pref_t,1); preference->name = name; @@ -834,9 +835,32 @@ register_preference(module_t *module, const char *name, const char *title, g_error("Preference %s begins with the module name", name); } + /* The title shows up in the preferences dialog. Make sure it's UI-friendly. */ + if (preference->title) { + const char *cur_char; + if (preference->type != PREF_STATIC_TEXT && strlen(preference->title) > 80) { // Arbitrary. + g_error("Title for preference %s.%s is too long: %s", name_prefix, preference->name, preference->title); + } + + if (!g_utf8_validate(preference->title, -1, NULL)) { + g_error("Title for preference %s.%s isn't valid UTF-8.", name_prefix, preference->name); + } + + for (cur_char = preference->title; *cur_char; cur_char = g_utf8_next_char(cur_char)) { + if (!g_unichar_isprint(g_utf8_get_char(cur_char))) { + g_error("Title for preference %s.%s isn't printable UTF-8.", name_prefix, preference->name); + } + } + } + + if (preference->description) { + if (!g_utf8_validate(preference->description, -1, NULL)) { + g_error("Description for preference %s.%s isn't valid UTF-8.", name_prefix, preference->name); + } + } + /* - * There isn't already one with that name, so add the - * preference. + * We passed all of our checks. Add the preference. */ module->prefs = g_list_append(module->prefs, preference); if (title != NULL) @@ -2436,13 +2460,15 @@ prefs_register_modules(void) (gint*)(void*)(&prefs.gui_version_placement), gui_version_placement_type, FALSE); prefs_register_bool_preference(gui_module, "auto_scroll_on_expand", - "Automatically scroll the recently expanded item", - "Automatically scroll the recently expanded item", + "Automatically scroll packet details", + "When selecting a new packet, automatically scroll" + "to the packet detail item that matches the most" + "recently selected item", &prefs.gui_auto_scroll_on_expand); prefs_register_uint_preference(gui_module, "auto_scroll_percentage", - "The percentage down the view the recently expanded item should be scrolled", - "The percentage down the view the recently expanded item should be scrolled", + "Packet detail scroll percentage", + "The percentage down the view the recently expanded detail item should be scrolled", 10, &prefs.gui_auto_scroll_percentage); @@ -5357,6 +5383,7 @@ write_pref(gpointer data, gpointer user_data) int type; type = pref->type; + if (IS_PREF_OBSOLETE(type)) { /* * This preference is no longer supported; it's not a diff --git a/epan/prefs.h b/epan/prefs.h index 912037431a..a64d363e58 100644 --- a/epan/prefs.h +++ b/epan/prefs.h @@ -421,8 +421,16 @@ WS_DLL_PUBLIC void prefs_register_uint_preference(module_t *module, const char * const char *title, const char *description, guint base, guint *var); /* + * prefs_register_ callers must conform to the following: + * + * Names must be in lowercase letters only (underscore allowed). + * Titles and descriptions must be valid UTF-8 or NULL. + * Titles must be short (less than 80 characters) + * Titles must not contain newlines. + */ + +/* * Register a preference with an Boolean value. - * Note that the name must be in lowercase letters only (underscore allowed). */ WS_DLL_PUBLIC void prefs_register_bool_preference(module_t *module, const char *name, const char *title, const char *description, gboolean *var); |