зеркало из https://github.com/mozilla/pjs.git
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:
Родитель
ab1b10458a
Коммит
8f74c45e82
|
@ -469,21 +469,26 @@ nsFtpState::OnDataAvailable(nsIRequest *request,
|
||||||
}
|
}
|
||||||
|
|
||||||
char* buffer = (char*)nsMemory::Alloc(aCount + 1);
|
char* buffer = (char*)nsMemory::Alloc(aCount + 1);
|
||||||
|
if (!buffer)
|
||||||
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
nsresult rv = aInStream->Read(buffer, aCount, &aCount);
|
nsresult rv = aInStream->Read(buffer, aCount, &aCount);
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
{
|
{
|
||||||
PR_LOG(gFTPLog, PR_LOG_DEBUG, ("(%x) nsFtpState - error reading %x\n", this, rv));
|
PR_LOG(gFTPLog, PR_LOG_DEBUG, ("(%x) nsFtpState - error reading %x\n", this, rv));
|
||||||
|
nsMemory::Free(buffer);
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
buffer[aCount] = '\0';
|
buffer[aCount] = '\0';
|
||||||
|
|
||||||
|
nsXPIDLCString data;
|
||||||
|
data.Adopt(buffer);
|
||||||
|
|
||||||
PR_LOG(gFTPLog, PR_LOG_DEBUG, ("(%x) reading %d bytes: \"%s\"", this, aCount, 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.
|
// Sometimes we can get two responses in the same packet, eg from LIST.
|
||||||
// So we need to parse the response line by line
|
// So we need to parse the response line by line
|
||||||
nsCString lines(mControlReadCarryOverBuf);
|
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
|
// Clear the carryover buf - if we still don't have a line, then it will
|
||||||
// be reappended below
|
// be reappended below
|
||||||
mControlReadCarryOverBuf.Truncate();
|
mControlReadCarryOverBuf.Truncate();
|
||||||
|
|
|
@ -410,7 +410,7 @@ nsIndexedToHTML::FormatInputStream(nsIRequest* aRequest, nsISupports *aContext,
|
||||||
|
|
||||||
nsCOMPtr<nsIInputStream> inputData;
|
nsCOMPtr<nsIInputStream> inputData;
|
||||||
if (buffer) {
|
if (buffer) {
|
||||||
rv = NS_NewCStringInputStream(getter_AddRefs(inputData), nsDependentCString(buffer, dstLength));
|
rv = NS_NewCStringInputStream(getter_AddRefs(inputData), Substring(buffer, buffer + dstLength));
|
||||||
nsMemory::Free(buffer);
|
nsMemory::Free(buffer);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
rv = mListener->OnDataAvailable(aRequest, aContext,
|
rv = mListener->OnDataAvailable(aRequest, aContext,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче