From c398858205724434bfcbec0ffed1f4223c2c85d1 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Fri, 14 Apr 2017 12:34:18 -0700 Subject: [PATCH] Give a better error message for invalid characters in preference module names. And make the message for an invalid character in a preference name more like it, by putting the offending name in quotes. Change-Id: I40db8b87eae5e46a1d49213a9a45861b6b3565af Reviewed-on: https://code.wireshark.org/review/21092 Reviewed-by: Guy Harris --- epan/prefs.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/epan/prefs.c b/epan/prefs.c index 293e8e1dbb..af8492b8e9 100644 --- a/epan/prefs.c +++ b/epan/prefs.c @@ -517,9 +517,11 @@ prefs_register_module_or_subtree(module_t *parent, const char *name, * on the command line, and shouldn't require quoting, * shifting, etc. */ - for (p = name; (c = *p) != '\0'; p++) - g_assert(g_ascii_islower(c) || g_ascii_isdigit(c) || c == '_' || - c == '-' || c == '.'); + for (p = name; (c = *p) != '\0'; p++) { + if (!(g_ascii_islower(c) || g_ascii_isdigit(c) || c == '_' || + c == '-' || c == '.')) + g_error("Preference module \"%s\" contains invalid characters", name); + } /* * Make sure there's not already a module with that @@ -916,7 +918,7 @@ register_preference(module_t *module, const char *name, const char *title, */ for (p = name; *p != '\0'; p++) if (!(g_ascii_islower(*p) || g_ascii_isdigit(*p) || *p == '_' || *p == '.')) - g_error("Preference %s.%s contains invalid characters", module->name, name); + g_error("Preference \"%s.%s\" contains invalid characters", module->name, name); /* * Make sure there's not already a preference with that