]> git.saurik.com Git - wxWidgets.git/commitdiff
properly detect missing data at the end of UTF-7-encoded segment and fail the convers...
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 17 Jul 2008 23:01:02 +0000 (23:01 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 17 Jul 2008 23:01:02 +0000 (23:01 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54670 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/strconv.cpp

index 54ac2c84894ead9adbf148c4d6aab4e94838d248..5d19539fc513ca2a0a3d9e975158fe7429b304bb 100644 (file)
@@ -543,7 +543,7 @@ size_t wxMBConvUTF7::ToWChar(wchar_t *dst, size_t dstLen,
                              const char *src, size_t srcLen) const
 {
     DecoderState stateOrig,
                              const char *src, size_t srcLen) const
 {
     DecoderState stateOrig,
-         *statePtr;
+                *statePtr;
     if ( srcLen == wxNO_LEN )
     {
         // convert the entire string, up to and including the trailing NUL
     if ( srcLen == wxNO_LEN )
     {
         // convert the entire string, up to and including the trailing NUL
@@ -580,7 +580,12 @@ size_t wxMBConvUTF7::ToWChar(wchar_t *dst, size_t dstLen,
             const unsigned char dc = utf7unb64[cc];
             if ( dc == 0xff )
             {
             const unsigned char dc = utf7unb64[cc];
             if ( dc == 0xff )
             {
-                // end of encoded part
+                // end of encoded part, check that nothing was left: the bit
+                // field cycles through 0,6,4,2 sequence so check that we're at
+                // the end of it
+                if ( state.bit != 2 )
+                    return wxCONV_FAILED;
+
                 state.ToDirect();
 
                 // re-parse this character normally below unless it's '-' which
                 state.ToDirect();
 
                 // re-parse this character normally below unless it's '-' which
@@ -624,9 +629,6 @@ size_t wxMBConvUTF7::ToWChar(wchar_t *dst, size_t dstLen,
             // start of an encoded segment?
             if ( cc == '+' )
             {
             // start of an encoded segment?
             if ( cc == '+' )
             {
-                if ( src == srcEnd )
-                    return wxCONV_FAILED; // can't have '+' at the end
-
                 if ( *src == '-' )
                 {
                     // just the encoded plus sign, don't switch to shifted mode
                 if ( *src == '-' )
                 {
                     // just the encoded plus sign, don't switch to shifted mode