[sword-svn] r2754 - trunk/src/mgr

scribe at crosswire.org scribe at crosswire.org
Sun Dec 30 19:55:29 MST 2012


Author: scribe
Date: 2012-12-30 19:55:29 -0700 (Sun, 30 Dec 2012)
New Revision: 2754

Modified:
   trunk/src/mgr/ftptrans.cpp
Log:
Added check to supress "." and ".." from directory lists (original patch from GHellings)
Assure ftp file name is null terminated



Modified: trunk/src/mgr/ftptrans.cpp
===================================================================
--- trunk/src/mgr/ftptrans.cpp	2012-12-22 19:24:45 UTC (rev 2753)
+++ trunk/src/mgr/ftptrans.cpp	2012-12-31 02:55:29 UTC (rev 2754)
@@ -101,10 +101,13 @@
 			}
 			SWLog::getSystemLog()->logWarning("FTPURLGetDir: parsing item %s(%d)\n", start, end-start);
 			int status = ftpparse(&item, start, end - start);
-			SWLog::getSystemLog()->logWarning("FTPURLGetDir: got item %s\n", item.name);
-			if (status) {
+			// in ftpparse.h, there is a warning that name is not necessarily null terminated
+			SWBuf name;
+			name.append(item.name, item.namelen);
+			SWLog::getSystemLog()->logWarning("FTPURLGetDir: got item %s\n", name.c_str());
+			if (status && name != "." && name != "..") {
 				struct DirEntry i;
-				i.name = item.name;
+				i.name = name;
 				i.size = item.size;
 				i.isDirectory = (item.flagtrycwd == 1);
 				dirList.push_back(i);
@@ -112,8 +115,7 @@
 			start = end;
 		}
 	}
-	else
-	{
+	else {
 		SWLog::getSystemLog()->logWarning("FTPURLGetDir: failed to get dir %s\n", dirURL);
 	}
 	return dirList;




More information about the sword-cvs mailing list