Bug 164197 - ftp leaks control channel data. Also fixes an ABR in the

indexed-to-html converter
r=deveditz, sr=darin
This commit is contained in:
bbaetz%student.usyd.edu.au 2002-08-24 00:48:58 +00:00
Родитель ab1b10458a
Коммит 8f74c45e82
2 изменённых файлов: 8 добавлений и 3 удалений

Просмотреть файл

@ -469,21 +469,26 @@ nsFtpState::OnDataAvailable(nsIRequest *request,
}
char* buffer = (char*)nsMemory::Alloc(aCount + 1);
if (!buffer)
return NS_ERROR_OUT_OF_MEMORY;
nsresult rv = aInStream->Read(buffer, aCount, &aCount);
if (NS_FAILED(rv))
{
PR_LOG(gFTPLog, PR_LOG_DEBUG, ("(%x) nsFtpState - error reading %x\n", this, rv));
nsMemory::Free(buffer);
return NS_ERROR_FAILURE;
}
buffer[aCount] = '\0';
nsXPIDLCString data;
data.Adopt(buffer);
PR_LOG(gFTPLog, PR_LOG_DEBUG, ("(%x) reading %d bytes: \"%s\"", this, aCount, buffer));
// Sometimes we can get two responses in the same packet, eg from LIST.
// So we need to parse the response line by line
nsCString lines(mControlReadCarryOverBuf);
lines.Append(buffer, aCount);
lines.Append(data, aCount);
// Clear the carryover buf - if we still don't have a line, then it will
// be reappended below
mControlReadCarryOverBuf.Truncate();

Просмотреть файл

@ -410,7 +410,7 @@ nsIndexedToHTML::FormatInputStream(nsIRequest* aRequest, nsISupports *aContext,
nsCOMPtr<nsIInputStream> inputData;
if (buffer) {
rv = NS_NewCStringInputStream(getter_AddRefs(inputData), nsDependentCString(buffer, dstLength));
rv = NS_NewCStringInputStream(getter_AddRefs(inputData), Substring(buffer, buffer + dstLength));
nsMemory::Free(buffer);
NS_ENSURE_SUCCESS(rv, rv);
rv = mListener->OnDataAvailable(aRequest, aContext,