diff --git a/src/mgr/curlhttpt.cpp b/src/mgr/curlhttpt.cpp
index c1c9589..b7edb1d 100644
--- a/src/mgr/curlhttpt.cpp
+++ b/src/mgr/curlhttpt.cpp
@@ -209,38 +209,41 @@ vector<struct DirEntry> CURLHTTPTransport::getDirList(const char *dirURL) {
 	SWBuf dirBuf;
 	const char *pBuf;
 	char *pBufRes;
-	char possibleName[400];
+	char *possibleName;
 	double fSize;
-	int possibleNameLength = 0;
+	int possibleNameLength;
 	
 	if (!getURL("", dirURL, &dirBuf)) {
 		pBuf = strstr(dirBuf, "<a href=\"");//Find the next link to a possible file name.
 		while (pBuf != NULL) {
 			pBuf += 9;//move to the start of the actual name.
 			pBufRes = (char *)strchr(pBuf, '\"');//Find the end of the possible file name
-			possibleNameLength = pBufRes - pBuf;
-			sprintf(possibleName, "%.*s", possibleNameLength, pBuf);
-			if (isalnum(possibleName[0])) {
-				SWLog::getSystemLog()->logDebug("getDirListHTTP: Found a file: %s", possibleName);
-				pBuf = pBufRes;
-				pBufRes = (char *)findSizeStart(pBuf);
-				fSize = 0;
-				if(pBufRes != NULL) {
+			if (pBufRes && (possibleNameLength = pBufRes - pBuf)>0){
+				possibleName = new char[possibleNameLength + 1];                                
+				sprintf(possibleName, "%.*s", possibleNameLength, pBuf);
+				if (isalnum(possibleName[0])) {
+					SWLog::getSystemLog()->logDebug("getDirListHTTP: Found a file: %s", possibleName);
 					pBuf = pBufRes;
-					fSize = strtod(pBuf, &pBufRes);
-					if (pBufRes[0] == 'K')
-						fSize *= 1024;
-					else if (pBufRes[0] == 'M')
-						fSize *= 1048576;
+					pBufRes = (char *)findSizeStart(pBuf);
+					fSize = 0;
+					if(pBufRes != NULL) {
+						pBuf = pBufRes;
+						fSize = strtod(pBuf, &pBufRes);
+						if (pBufRes[0] == 'K')
+							fSize *= 1024;
+						else if (pBufRes[0] == 'M')
+							fSize *= 1048576;
+						pBuf = pBufRes;
+					}
+					struct DirEntry i;
+					i.name = possibleName;
+						i.size = (long unsigned int)fSize;
+					i.isDirectory = (possibleName[possibleNameLength-1] == '/');
+					dirList.push_back(i);
+				} else {
+					pBuf += possibleNameLength;
 				}
-				struct DirEntry i;
-				i.name = possibleName;
-				i.size = (long unsigned int)fSize;
-				i.isDirectory = (possibleName[possibleNameLength-1] == '/');
-				dirList.push_back(i);
-				pBuf = pBufRes;
-			} else {
-				pBuf += possibleNameLength;
+				delete[] possibleName;
 			}
 			pBuf++;
 			pBuf = strstr(pBuf, "<a href=\"");//Find the next link to a possible file name.
