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>
This commit is contained in:
Gerald Combs 2016-09-20 14:11:29 -07:00 committed by Michael Mann
parent 9887cd7feb
commit cbf89c8ed8
14 changed files with 63 additions and 32 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -965,11 +965,11 @@ proto_register_eth(void)
&eth_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",

View File

@ -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);
}

View File

@ -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",

View File

@ -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);

View File

@ -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);

View File

@ -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",

View File

@ -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.",

View File

@ -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);

View File

@ -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

View File

@ -420,9 +420,17 @@ WS_DLL_PUBLIC pref_t *prefs_find_preference(module_t * module, const char *pref)
WS_DLL_PUBLIC void prefs_register_uint_preference(module_t *module, const char *name,
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);