When --spice-color-depth is used, error out unless the color depth is 16 or 32. Fixes rhbz#818847 --- gtk/spice-option.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/gtk/spice-option.c b/gtk/spice-option.c index ea5d226..c65397a 100644 --- a/gtk/spice-option.c +++ b/gtk/spice-option.c @@ -52,6 +52,33 @@ static gboolean option_debug(void) return TRUE; } +static gboolean parse_color_depth(const gchar *option_name, const gchar *value, + gpointer data, GError **error) +{ + unsigned long parsed_depth; + char *end; + + if (option_name == NULL) { + g_set_error(error, G_OPTION_ERROR, G_OPTION_ERROR_FAILED, _("missing color depth, must be 16 or 32")); + return FALSE; + } + + parsed_depth = strtoul(value, &end, 0); + if (*end != '\0') + goto error; + + if ((parsed_depth != 16) && (parsed_depth != 32)) + goto error; + + color_depth = parsed_depth; + + return TRUE; + +error: + g_set_error(error, G_OPTION_ERROR, G_OPTION_ERROR_FAILED, _("invalid color depth (%s), must be 16 or 32"), value); + return FALSE; +} + /** * spice_get_option_group: * @@ -65,7 +92,7 @@ GOptionGroup* spice_get_option_group(void) const GOptionEntry entries[] = { { "spice-disable-effects", '\0', 0, G_OPTION_ARG_STRING, &disable_effects, N_("Disable guest display effects"), N_("<wallpaper,font-smooth,animation,all>") }, - { "spice-color-depth", '\0', 0, G_OPTION_ARG_INT, &color_depth, + { "spice-color-depth", '\0', 0, G_OPTION_ARG_CALLBACK, parse_color_depth, N_("Guest display color depth"), N_("<16,32>") }, { "spice-ca-file", '\0', 0, G_OPTION_ARG_FILENAME, &ca_file, N_("Truststore file for secure connections"), N_("<file>") }, -- 1.7.11.2 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/spice-devel