From d41e3499c9d77aacc54f0fd3cc42ed85ec008f8a Mon Sep 17 00:00:00 2001 From: Přemysl Janouch Date: Thu, 14 May 2015 06:45:24 +0200 Subject: degesch: prevent playing with unknown options --- degesch.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'degesch.c') diff --git a/degesch.c b/degesch.c index 5b54e0d..fe9469b 100644 --- a/degesch.c +++ b/degesch.c @@ -4591,7 +4591,9 @@ config_dump_item (struct config_item_ *item, struct config_dump_data *data) config_item_write (item, false, &value); str_append_str (&line, &value); - if (has_default && strcmp (schema->default_, value.str)) + if (!schema) + str_append (&line, " (unrecognized)"); + else if (has_default && strcmp (schema->default_, value.str)) str_append_printf (&line, " (default: %s)", schema->default_); else if (!has_default && item->type != CONFIG_ITEM_NULL) str_append_printf (&line, " (default: %s)", "null"); @@ -4837,7 +4839,9 @@ handle_command_set_assign_item (struct app_context *ctx, hard_assert (item); struct error *e = NULL; - if ((add | remove) && item->type != CONFIG_ITEM_STRING_ARRAY) + if (!item->schema) + error_set (&e, "option not recognized"); + else if ((add | remove) && item->type != CONFIG_ITEM_STRING_ARRAY) // FIXME: it can also be null, which makes this message confusing error_set (&e, "not a string array"); else if (add) @@ -5301,7 +5305,7 @@ try_handle_command_help_option (struct app_context *ctx, const char *name) if (!schema) { buffer_send_error (ctx, ctx->global_buffer, - "%s: %s", "This option has no schema", name); + "%s: %s", "Option not recognized", name); return true; } -- cgit v1.2.3-54-g00ecf