From 6ca97a5e22a8b5e6c27bd97fb5fdc24317838e8a Mon Sep 17 00:00:00 2001 From: "shanjian%netscape.com" Date: Mon, 28 Oct 2002 22:56:03 +0000 Subject: [PATCH] #172700 NS_ConvertUTF8ToUCS2() surrogates buffer overflow allocate enough space for surrogate. p=jgmyers, r=shanjian, sr=dbaron, a=blizzard git-svn-id: svn://10.0.0.236/trunk@132607 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/string/obsolete/nsString2.cpp | 4 +++- mozilla/xpcom/string/obsolete/nsString2.cpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/mozilla/string/obsolete/nsString2.cpp b/mozilla/string/obsolete/nsString2.cpp index a2886e5ffb6..8a6043a0a98 100644 --- a/mozilla/string/obsolete/nsString2.cpp +++ b/mozilla/string/obsolete/nsString2.cpp @@ -1389,8 +1389,10 @@ class CalculateUTF8Length p += 2; else if ( UTF8traits::is3byte(*p) ) p += 3; - else if ( UTF8traits::is4byte(*p) ) + else if ( UTF8traits::is4byte(*p) ) { p += 4; + ++mLength; + } else if ( UTF8traits::is5byte(*p) ) p += 5; else if ( UTF8traits::is6byte(*p) ) diff --git a/mozilla/xpcom/string/obsolete/nsString2.cpp b/mozilla/xpcom/string/obsolete/nsString2.cpp index a2886e5ffb6..8a6043a0a98 100644 --- a/mozilla/xpcom/string/obsolete/nsString2.cpp +++ b/mozilla/xpcom/string/obsolete/nsString2.cpp @@ -1389,8 +1389,10 @@ class CalculateUTF8Length p += 2; else if ( UTF8traits::is3byte(*p) ) p += 3; - else if ( UTF8traits::is4byte(*p) ) + else if ( UTF8traits::is4byte(*p) ) { p += 4; + ++mLength; + } else if ( UTF8traits::is5byte(*p) ) p += 5; else if ( UTF8traits::is6byte(*p) )