зеркало из https://github.com/mozilla/pjs.git
Bug 373899: Add checks to nsStandardURL. r=honzab
This commit is contained in:
Родитель
63b7eeab4d
Коммит
0623ead32d
|
@ -855,11 +855,23 @@ nsStandardURL::ParsePath(const char *spec, PRUint32 pathPos, PRInt32 pathLen)
|
||||||
char *
|
char *
|
||||||
nsStandardURL::AppendToSubstring(PRUint32 pos,
|
nsStandardURL::AppendToSubstring(PRUint32 pos,
|
||||||
PRInt32 len,
|
PRInt32 len,
|
||||||
const char *tail,
|
const char *tail)
|
||||||
PRInt32 tailLen)
|
|
||||||
{
|
{
|
||||||
if (tailLen < 0)
|
// Verify pos and length are within boundaries
|
||||||
tailLen = strlen(tail);
|
if (pos > mSpec.Length())
|
||||||
|
return NULL;
|
||||||
|
if (len < 0)
|
||||||
|
return NULL;
|
||||||
|
if ((PRUint32)len > (mSpec.Length() - pos))
|
||||||
|
return NULL;
|
||||||
|
if (!tail)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
PRUint32 tailLen = strlen(tail);
|
||||||
|
|
||||||
|
// Check for int overflow for proposed length of combined string
|
||||||
|
if (PR_UINT32_MAX - ((PRUint32)len + 1) < tailLen)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
char *result = (char *) NS_Alloc(len + tailLen + 1);
|
char *result = (char *) NS_Alloc(len + tailLen + 1);
|
||||||
if (result) {
|
if (result) {
|
||||||
|
|
|
@ -214,7 +214,7 @@ private:
|
||||||
nsresult ParseURL(const char *spec, PRInt32 specLen);
|
nsresult ParseURL(const char *spec, PRInt32 specLen);
|
||||||
nsresult ParsePath(const char *spec, PRUint32 pathPos, PRInt32 pathLen = -1);
|
nsresult ParsePath(const char *spec, PRUint32 pathPos, PRInt32 pathLen = -1);
|
||||||
|
|
||||||
char *AppendToSubstring(PRUint32 pos, PRInt32 len, const char *tail, PRInt32 tailLen = -1);
|
char *AppendToSubstring(PRUint32 pos, PRInt32 len, const char *tail);
|
||||||
|
|
||||||
// dependent substring helpers
|
// dependent substring helpers
|
||||||
const nsDependentCSubstring Segment(PRUint32 pos, PRInt32 len); // see below
|
const nsDependentCSubstring Segment(PRUint32 pos, PRInt32 len); // see below
|
||||||
|
|
Загрузка…
Ссылка в новой задаче