]> granicus.if.org Git - mutt/commitdiff
Error handling fixes.
authorMichael Elkins <me@sigpipe.org>
Mon, 5 Aug 2002 17:24:55 +0000 (17:24 +0000)
committerMichael Elkins <me@sigpipe.org>
Mon, 5 Aug 2002 17:24:55 +0000 (17:24 +0000)
pgpewrap.c
pgppubring.c

index 81e8f801fdde07ed1b15f1d64ded4ef583b9a190..d88948382aa64088a25d0cf3aba442009c554c4c 100644 (file)
@@ -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;
index 5e852b2afbfac4114791af21df534639ba014215..7dd3a4455650ddd8d92f5780cc4d59a6f8b9e9d6 100644 (file)
@@ -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;
   }