]> sjero.net Git - wget/blobdiff - src/netrc.c
[svn] Applied Philipp Thomas's safe-ctype patch. Published in
[wget] / src / netrc.c
index 432a8c17e215243d6c2412f7c51e0168f9635870..7f7601a24738326f2a917bebffeb3088ba5e1d63 100644 (file)
@@ -25,7 +25,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #endif
 
 #include <stdio.h>
-#include <ctype.h>
 #include <stdlib.h>
 #ifdef HAVE_STRING_H
 # include <string.h>
@@ -143,6 +142,7 @@ search_netrc (const char *host, const char **acc, const char **passwd,
 #ifdef STANDALONE
 /* Normally, these functions would be defined by your package.  */
 # define xmalloc malloc
+# define xfree free
 # define xstrdup strdup
 
 /* The function reads a whole line.  It reads the line realloc-ing the
@@ -269,6 +269,13 @@ parse_netrc (const char *path)
   /* While there are lines in the file...  */
   while ((line = read_whole_line (fp)))
     {
+      /* Do away with line separators. */
+      int len = strlen (line);
+      if (len && line[len - 1] == '\n')
+       line[--len] = '\0';
+      if (len && line[len - 1] == '\r')
+       line[--len] = '\0';
+
       ln ++;
 
       /* Parse the line.  */