Check adjust mode argument

Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This commit is contained in:
Sebastian Ramacher 2016-11-06 18:23:25 +01:00
parent 10641d688d
commit bcdc7aba05
3 changed files with 12 additions and 4 deletions

View File

@ -100,8 +100,15 @@ sc_adjust_window(girara_session_t* session, girara_argument_t* argument,
zathura_t* zathura = session->global.data;
g_return_val_if_fail(argument != NULL, false);
zathura_document_set_adjust_mode(zathura->document, argument->n);
adjust_view(zathura);
if (argument->n < ZATHURA_ADJUST_NONE || argument->n >= ZATHURA_ADJUST_MODE_NUMBER) {
girara_error("Invalid adjust mode: %d", argument->n);
girara_notify(session, GIRARA_ERROR, _("Invalid adjust mode: %d"), argument->n);
} else {
girara_debug("Setting adjust mode to: %d", argument->n);
zathura_document_set_adjust_mode(zathura->document, argument->n);
adjust_view(zathura);
}
return false;
}

View File

@ -101,7 +101,8 @@ typedef enum zathura_adjust_mode_e
ZATHURA_ADJUST_NONE, /**< No adjustment */
ZATHURA_ADJUST_BESTFIT, /**< Adjust to best-fit */
ZATHURA_ADJUST_WIDTH, /**< Adjust to width */
ZATHURA_ADJUST_INPUTBAR /**< Focusing the inputbar */
ZATHURA_ADJUST_INPUTBAR, /**< Focusing the inputbar */
ZATHURA_ADJUST_MODE_NUMBER /**< Number of adjust modes */
} zathura_adjust_mode_t;
/**

View File

@ -121,7 +121,7 @@ error_out:
static void
create_directories(zathura_t* zathura)
{
static const unsigned int mode = 0711;
static const unsigned int mode = 0700;
if (g_mkdir_with_parents(zathura->config.config_dir, mode) == -1) {
girara_error("Could not create '%s': %s", zathura->config.config_dir,