mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 08:15:31 +00:00
Bug 1484984 - Avoid writing past the logical length of a string in networking code. r=valentin
MozReview-Commit-ID: IIffoxnF6KS Differential Revision: https://phabricator.services.mozilla.com/D3884 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
9cbf625f78
commit
57d5f3ee13
@ -886,7 +886,7 @@ HttpConnInfo::SetHTTP2ProtocolVersion(SpdyVersion pv)
|
||||
NS_IMETHODIMP
|
||||
Dashboard::GetLogPath(nsACString &aLogPath)
|
||||
{
|
||||
aLogPath.SetCapacity(2048);
|
||||
aLogPath.SetLength(2048);
|
||||
uint32_t len = LogModule::GetLogFile(aLogPath.BeginWriting(), 2048);
|
||||
aLogPath.SetLength(len);
|
||||
return NS_OK;
|
||||
|
@ -45,12 +45,12 @@ NS_IMETHODIMP nsNetAddr::GetAddress(nsACString & aAddress)
|
||||
switch(mAddr.raw.family) {
|
||||
/* PR_NetAddrToString can handle INET and INET6, but not LOCAL. */
|
||||
case AF_INET:
|
||||
aAddress.SetCapacity(kIPv4CStrBufSize);
|
||||
aAddress.SetLength(kIPv4CStrBufSize);
|
||||
NetAddrToString(&mAddr, aAddress.BeginWriting(), kIPv4CStrBufSize);
|
||||
aAddress.SetLength(strlen(aAddress.BeginReading()));
|
||||
break;
|
||||
case AF_INET6:
|
||||
aAddress.SetCapacity(kIPv6CStrBufSize);
|
||||
aAddress.SetLength(kIPv6CStrBufSize);
|
||||
NetAddrToString(&mAddr, aAddress.BeginWriting(), kIPv6CStrBufSize);
|
||||
aAddress.SetLength(strlen(aAddress.BeginReading()));
|
||||
break;
|
||||
|
@ -1344,7 +1344,7 @@ nsSocketTransport::InitiateSocket()
|
||||
IsIPAddrLocal(&mNetAddr)) {
|
||||
if (SOCKET_LOG_ENABLED()) {
|
||||
nsAutoCString netAddrCString;
|
||||
netAddrCString.SetCapacity(kIPv6CStrBufSize);
|
||||
netAddrCString.SetLength(kIPv6CStrBufSize);
|
||||
if (!NetAddrToString(&mNetAddr,
|
||||
netAddrCString.BeginWriting(),
|
||||
kIPv6CStrBufSize))
|
||||
|
@ -1092,8 +1092,8 @@ Http2Compressor::EncodeHeaderBlock(const nsCString &nvInput,
|
||||
{
|
||||
mSetInitialMaxBufferSizeAllowed = false;
|
||||
mOutput = &output;
|
||||
output.SetCapacity(1024);
|
||||
output.Truncate();
|
||||
output.SetCapacity(1024);
|
||||
mParsedContentLength = -1;
|
||||
|
||||
// first thing's first - context size updates (if necessary)
|
||||
|
@ -2591,7 +2591,7 @@ HttpBaseChannel::GetLocalAddress(nsACString& addr)
|
||||
if (mSelfAddr.raw.family == PR_AF_UNSPEC)
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
addr.SetCapacity(kIPv6CStrBufSize);
|
||||
addr.SetLength(kIPv6CStrBufSize);
|
||||
NetAddrToString(&mSelfAddr, addr.BeginWriting(), kIPv6CStrBufSize);
|
||||
addr.SetLength(strlen(addr.BeginReading()));
|
||||
|
||||
@ -2700,7 +2700,7 @@ HttpBaseChannel::GetRemoteAddress(nsACString& addr)
|
||||
if (mPeerAddr.raw.family == PR_AF_UNSPEC)
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
addr.SetCapacity(kIPv6CStrBufSize);
|
||||
addr.SetLength(kIPv6CStrBufSize);
|
||||
NetAddrToString(&mPeerAddr, addr.BeginWriting(), kIPv6CStrBufSize);
|
||||
addr.SetLength(strlen(addr.BeginReading()));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user