summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustus Winter <justus@gnupg.org>2016-10-05 10:24:59 +0200
committerJustus Winter <justus@gnupg.org>2016-10-05 10:24:59 +0200
commit3a3c1759297d3621663571dc85d2fb5d1d53b3b1 (patch)
tree3880da46eb102bede70cdfc023f58ecd3444ebe4
parente6bffe8d286d49311c0d34acab4b9da867e0dfe8 (diff)
Avoid fatal error handling in option parsers.
* trans/crash.c (parse_opt): Avoid 'error' in favor of the appropriate argp error reporting mechanism. * trans/remap.c (parse_opt): Likewise. * utils/msgids.c (parse_opt): Likewise.
-rw-r--r--trans/crash.c5
-rw-r--r--trans/remap.c6
-rw-r--r--utils/msgids.c5
3 files changed, 13 insertions, 3 deletions
diff --git a/trans/crash.c b/trans/crash.c
index 14783cf8..3c244515 100644
--- a/trans/crash.c
+++ b/trans/crash.c
@@ -640,7 +640,10 @@ parse_opt (int opt, char *arg, struct argp_state *state)
{
char *errp;
if (! template_valid (arg, &errp))
- error (1, 0, "Invalid template: ...'%s'", errp);
+ {
+ argp_error (state, "Invalid template: ...'%s'", errp);
+ return EINVAL;
+ }
}
corefile_template = arg;
break;
diff --git a/trans/remap.c b/trans/remap.c
index 63434f0f..5afbaa02 100644
--- a/trans/remap.c
+++ b/trans/remap.c
@@ -98,7 +98,11 @@ parse_opt (int key, char *arg, struct argp_state *state)
{
case ARGP_KEY_ARG:
if (arg[0] != '/')
- error (1, 0, "remap only works with absolute paths\n");
+ {
+ argp_error (state, "remap only works with absolute paths: %s",
+ arg);
+ return EINVAL;
+ }
/* Skip heading slashes */
while (arg[0] == '/')
diff --git a/utils/msgids.c b/utils/msgids.c
index 4bc08ded..d17f1316 100644
--- a/utils/msgids.c
+++ b/utils/msgids.c
@@ -200,7 +200,10 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state)
case 'i':
if (argz_add (&msgids_files_argz, &msgids_files_argz_len,
arg) != 0)
- error (1, errno, "argz_add");
+ {
+ argp_failure (state, 1, errno, "argz_add");
+ return errno;
+ }
break;
case 'I':