From c0a8b69048609da361a3aa8dbaa275ff289382de Mon Sep 17 00:00:00 2001 From: "bratell%lysator.liu.se" Date: Wed, 26 Jul 2000 00:05:55 +0000 Subject: [PATCH] Bug 40027, reads past buffer in nsString::ToCString, r,a=waterson --- string/obsolete/nsString.cpp | 2 +- xpcom/ds/nsString.cpp | 2 +- xpcom/string/obsolete/nsString.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/string/obsolete/nsString.cpp b/string/obsolete/nsString.cpp index 067b7073df4e..21e016f50161 100644 --- a/string/obsolete/nsString.cpp +++ b/string/obsolete/nsString.cpp @@ -689,7 +689,7 @@ char* nsCString::ToCString(char* aBuf, PRUint32 aBufLength,PRUint32 anOffset) co CBufDescriptor theDescr(aBuf,PR_TRUE,aBufLength,0); nsCAutoString temp(theDescr); - temp.Assign(*this,aBufLength-1); + temp.Assign(*this, PR_MIN(mLength, aBufLength-1)); temp.mStr=0; } return aBuf; diff --git a/xpcom/ds/nsString.cpp b/xpcom/ds/nsString.cpp index 067b7073df4e..21e016f50161 100644 --- a/xpcom/ds/nsString.cpp +++ b/xpcom/ds/nsString.cpp @@ -689,7 +689,7 @@ char* nsCString::ToCString(char* aBuf, PRUint32 aBufLength,PRUint32 anOffset) co CBufDescriptor theDescr(aBuf,PR_TRUE,aBufLength,0); nsCAutoString temp(theDescr); - temp.Assign(*this,aBufLength-1); + temp.Assign(*this, PR_MIN(mLength, aBufLength-1)); temp.mStr=0; } return aBuf; diff --git a/xpcom/string/obsolete/nsString.cpp b/xpcom/string/obsolete/nsString.cpp index 067b7073df4e..21e016f50161 100644 --- a/xpcom/string/obsolete/nsString.cpp +++ b/xpcom/string/obsolete/nsString.cpp @@ -689,7 +689,7 @@ char* nsCString::ToCString(char* aBuf, PRUint32 aBufLength,PRUint32 anOffset) co CBufDescriptor theDescr(aBuf,PR_TRUE,aBufLength,0); nsCAutoString temp(theDescr); - temp.Assign(*this,aBufLength-1); + temp.Assign(*this, PR_MIN(mLength, aBufLength-1)); temp.mStr=0; } return aBuf;