From: Michael Elkins Date: Mon, 5 Aug 2002 17:24:55 +0000 (+0000) Subject: Error handling fixes. X-Git-Tag: mutt-1-5-2-rel~64 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5f95840a93381672a13be3da9a8ef5ccab967eec;p=mutt Error handling fixes. --- diff --git a/pgpewrap.c b/pgpewrap.c index 81e8f801..d8894838 100644 --- a/pgpewrap.c +++ b/pgpewrap.c @@ -20,6 +20,14 @@ int main(int argc, char **argv) { exit(2); } + if (argc < 2) + { + fprintf (stderr, + "Command line usage: %s [flags] -- prefix [recipients]\n", + argv[0]); + return 1; + } + opt = opts; *opt++ = argv[1]; pfx = NULL; diff --git a/pgppubring.c b/pgppubring.c index 5e852b2a..7dd3a445 100644 --- a/pgppubring.c +++ b/pgppubring.c @@ -45,6 +45,7 @@ #ifdef HAVE_GETOPT_H # include #endif +#include extern char *optarg; extern int optind; @@ -758,7 +759,14 @@ static void pgpring_find_candidates (char *ringfile, const char *hints[], int nh if ((rfp = fopen (ringfile, "r")) == NULL) { - perror ("fopen"); + char *error_buf; + size_t error_buf_len; + + error_buf_len = sizeof ("fopen: ") - 1 + strlen (ringfile) + 1; + error_buf = malloc (error_buf_len); + snprintf (error_buf, error_buf_len, "fopen: %s", ringfile); + perror (error_buf); + free (error_buf); return; }