Commit 5f95840a authored by Michael Elkins's avatar Michael Elkins

Error handling fixes.

parent 6228a8f4
......@@ -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;
......
......@@ -45,6 +45,7 @@
#ifdef HAVE_GETOPT_H
# include <getopt.h>
#endif
#include <errno.h>
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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment