From f2cc543baf85836ad186060a4be816850cd64577 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Mon, 26 Jul 2010 12:12:43 +0300 Subject: [PATCH] * fix error handling of shell expansion (candidate fix for issue #23) --- src/mu-cmd-index.c | 6 +++--- src/mu-util.c | 13 +++++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/mu-cmd-index.c b/src/mu-cmd-index.c index a7d05007..7186c5db 100644 --- a/src/mu-cmd-index.c +++ b/src/mu-cmd-index.c @@ -78,9 +78,9 @@ check_index_params (MuConfigOptions *opts) g_warning ("Error: Invalid option(s) for command\n"); return FALSE; } - - if (!g_path_is_absolute (opts->maildir)) { - g_warning ("Error: maildir path must be absolute\n"); + + if (!opts->maildir || !g_path_is_absolute (opts->maildir)) { + g_warning ("Error: maildir path is not valid\n"); return FALSE; } diff --git a/src/mu-util.c b/src/mu-util.c index dea43755..593fe1d4 100644 --- a/src/mu-util.c +++ b/src/mu-util.c @@ -37,14 +37,18 @@ mu_util_dir_expand (const char *path) { wordexp_t wexp; char *dir; + int rv; g_return_val_if_fail (path, NULL); dir = NULL; - wordexp (path, &wexp, 0); - if (wexp.we_wordc != 1) - g_warning ("error expanding dir '%s'", path); - else + + rv = wordexp (path, &wexp, 0); + if (rv != 0) { + g_warning ("%s: expansion failed for '%s' [%d]", + __FUNCTION__, path, rv); + return NULL; + } else dir = g_strdup (wexp.we_wordv[0]); wordfree (&wexp); @@ -52,6 +56,7 @@ mu_util_dir_expand (const char *path) return dir; } + gboolean mu_util_check_dir (const gchar* path, gboolean readable, gboolean writeable) {