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
parent f4e43b7f45
commit e74d597519
2 changed files with 8 additions and 3 deletions

View File

@ -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();

View File

@ -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,