]> sjero.net Git - wget/blobdiff - src/ftp-ls.c
[svn] Fix obvious memory leaks in the VMS directory parser.
[wget] / src / ftp-ls.c
index 28fcf9c2913e197bb0f3c90dd3d9b2965b4040d4..bf613b24938d4374aceca650afd9b06c93a0deaf 100644 (file)
@@ -1,21 +1,21 @@
 /* Parsing FTP `ls' output.
-   Copyright (C) 1995, 1996, 1997, 2000, 2001 Free Software Foundation,
-   Inc. 
+   Copyright (C) 1995, 1996, 1997, 2000, 2001
+   Free Software Foundation, Inc. 
 
-This file is part of Wget.
+This file is part of GNU Wget.
 
-This program is free software; you can redistribute it and/or modify
+GNU Wget is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.
 
-This program is distributed in the hope that it will be useful,
+GNU Wget is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
+along with Wget; if not, write to the Free Software
 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 #include <config.h>
@@ -577,19 +577,31 @@ ftp_parse_vms_ls (const char *file)
     }
   dir = l = NULL;
 
-  /* Empty line */
-  read_whole_line (fp);
-  /* "Directory PUB$DEVICE[PUB]" */
-  read_whole_line (fp);
-  /* Empty line */
-  read_whole_line (fp);
+  /* Skip empty line. */
+  line = read_whole_line (fp);
+  if (line)
+    xfree (line);
+
+  /* Skip "Directory PUB$DEVICE[PUB]" */
+  line = read_whole_line (fp);
+  if (line)
+    xfree (line);
+
+  /* Skip empty line. */
+  line = read_whole_line (fp);
+  if (line)
+    xfree (line);
 
   /* Line loop to end of file: */
   while ((line = read_whole_line (fp)))
     {
       char *p;
       i = clean_line (line);
-      if (!i) break;
+      if (!i)
+       {
+         xfree (line);
+         break;
+       }
 
       /* First column: Name. A bit of black magic again. The name my be
          either ABCD.EXT or ABCD.EXT;NUM and it might be on a separate
@@ -646,6 +658,7 @@ ftp_parse_vms_ls (const char *file)
         if (!i) 
         {
           DEBUGP(("confusing VMS listing item, leaving listing parser\n"));
+         xfree (line);
           break;
         }
         tok = strtok(line, " ");
@@ -665,6 +678,7 @@ ftp_parse_vms_ls (const char *file)
            the first strtok(NULL, "-") will return everything until the end
            of the line and only the next strtok() call will return NULL. */
         DEBUGP(("nonsense in VMS listing, skipping this line\n"));
+       xfree (line);
         break;
       }
       for (i=0; i<12; i++) if (!strcmp(tok,months[i])) break;
@@ -714,6 +728,7 @@ ftp_parse_vms_ls (const char *file)
       if (tok == NULL)
         {
           DEBUGP(("confusing VMS permissions, skipping line\n"));
+         xfree (line);
           continue;
         }
       /* Permissons have the format "RWED,RWED,RE" */
@@ -785,7 +800,7 @@ ftp_parse_ls (const char *file, const enum stype system_type)
       return ftp_parse_unix_ls (file, TRUE);
     default:
       logprintf (LOG_NOTQUIET, _("\
-Usupported listing type, trying Unix listing parser.\n"));
+Unsupported listing type, trying Unix listing parser.\n"));
       return ftp_parse_unix_ls (file, FALSE);
     }
 }
@@ -796,7 +811,7 @@ Usupported listing type, trying Unix listing parser.\n"));
    directories and files on the appropriate host.  The references are
    FTP.  */
 uerr_t
-ftp_index (const char *file, struct urlinfo *u, struct fileinfo *f)
+ftp_index (const char *file, struct url *u, struct fileinfo *f)
 {
   FILE *fp;
   char *upwd;