]> Pileus Git - ~andy/fetchmail/blobdiff - netrc.c
Merge branch 'legacy_63'
[~andy/fetchmail] / netrc.c
diff --git a/netrc.c b/netrc.c
index 765f5f1d1ac90e434978718e22fac0ce4b67cd35..5af542735349214d901c9f0f0f0ad5f366ede832 100644 (file)
--- a/netrc.c
+++ b/netrc.c
    (Makefile.am should have a rule so you can just type "make netrc")
 */
 
+#define _XOPEN_SOURCE 600
+
+#include "config.h"
+
 #include <stdio.h>
 #include <ctype.h>
 #include <stdlib.h>
 #include <string.h>
 
-#include "config.h"
 #include "fetchmail.h"
 #include "netrc.h"
-#include "i18n.h"
+#include "gettext.h"
 
 #ifdef STANDALONE
 /* Normally defined in xstrdup.c. */
@@ -28,7 +31,7 @@
 # define xmalloc malloc
 # define xrealloc realloc
 
-char *program_name = "netrc";
+const char *program_name = "netrc";
 #endif
 
 /* Maybe add NEWENTRY to the account information list, LIST.  NEWENTRY is
@@ -76,8 +79,7 @@ maybe_add_to_list (netrc_entry **newentry, netrc_entry **list)
    list of entries.  NULL is returned if the file could not be
    parsed. */
 netrc_entry *
-parse_netrc (file)
-     char *file;
+parse_netrc (char *file)
 {
     FILE *fp;
     char buf[POPBUFSIZE+1], *p, *tok;
@@ -291,9 +293,7 @@ parse_netrc (file)
 /* Return the netrc entry from LIST corresponding to HOST.  NULL is
    returned if no such entry exists. */
 netrc_entry *
-search_netrc (list, host, login)
-     netrc_entry *list;
-     char *host, *login;
+search_netrc (netrc_entry *list, char *host, char *login)
 {
     /* Look for the HOST in LIST. */
     while (list)
@@ -310,6 +310,20 @@ search_netrc (list, host, login)
     return list;
 }
 
+void
+free_netrc(netrc_entry *a) {
+    while(a) {
+       netrc_entry *n = a->next;
+       if (a->password != NULL) {
+               memset(a->password, 0x55, strlen(a->password));
+               free(a->password);
+       }
+       xfree(a->login);
+       xfree(a->host);
+       xfree(a);
+       a = n;
+    }
+}
 
 #ifdef STANDALONE
 #include <sys/types.h>
@@ -320,7 +334,7 @@ search_netrc (list, host, login)
 int main (int argc, char **argv)
 {
     struct stat sb;
-    char *program_name, *file, *host, *login;
+    char *file, *host, *login;
     netrc_entry *head, *a;
 
     program_name = argv[0];
@@ -399,6 +413,8 @@ int main (int argc, char **argv)
        a = a->next;
     }
 
+    free_netrc(head);
+
     exit (0);
 }
 #endif /* STANDALONE */