mmsengine/mmscodec/src/mmsdecode.cpp
changeset 72 6f657153cbc5
parent 31 ebfee66fde93
equal deleted inserted replaced
70:a15d9966050f 72:6f657153cbc5
  2144         {
  2144         {
  2145         // simple text string. Restart.
  2145         // simple text string. Restart.
  2146         // (includes empty strings)
  2146         // (includes empty strings)
  2147         // Keep quote because these are strange strings that may contain any
  2147         // Keep quote because these are strange strings that may contain any
  2148         // number of quotes all over the place
  2148         // number of quotes all over the place
       
  2149 
       
  2150 		// coverity[size_error][buffer_alloc]
  2149         buffer = GetSimpleTextStringL( ETrue );
  2151         buffer = GetSimpleTextStringL( ETrue );
  2150         // check if this looks like it needs decoding of MIME stuff (RFC2047)
  2152         // check if this looks like it needs decoding of MIME stuff (RFC2047)
  2151         if ( buffer->Des().FindF( KEqualsQuestion16 ) == KErrNotFound )
  2153         if ( buffer->Des().FindF( KEqualsQuestion16 ) == KErrNotFound )
  2152             {
  2154             {
  2153             return buffer;
  2155             return buffer;
  2279         buffer = HBufC16::NewL(0);
  2281         buffer = HBufC16::NewL(0);
  2280         return buffer;
  2282         return buffer;
  2281         }
  2283         }
  2282 
  2284 
  2283     stringLength--; // remove the terminating zero
  2285     stringLength--; // remove the terminating zero
  2284     buffer = HBufC16::NewL( stringLength * KMms2 );
  2286     // coverity[incorrect_multiplication][buffer_alloc]
       
  2287 	buffer = HBufC16::NewL( stringLength * KMms2 );
  2285 
  2288 
  2286     if ( stringLength == 0 )
  2289     if ( stringLength == 0 )
  2287         {
  2290         {
  2288         // buffer has zero length
  2291         // buffer has zero length
  2289         // I assume this is an empty string
  2292         // I assume this is an empty string
  3402         {
  3405         {
  3403         case KWspContentLocation:
  3406         case KWspContentLocation:
  3404             {
  3407             {
  3405             // I hope this is a simple text string. we cannot handle
  3408             // I hope this is a simple text string. we cannot handle
  3406             // different character sets in this context.
  3409             // different character sets in this context.
  3407 
  3410 			// coverity[size_error][buffer_alloc]
  3408             buffer = GetSimpleTextStringL(); // we might try to convert from utf8 to unicode
  3411             buffer = GetSimpleTextStringL(); // we might try to convert from utf8 to unicode
  3409             CleanupStack::PushL( buffer );
  3412             CleanupStack::PushL( buffer );
  3410             iMimeHeaders->SetContentLocationL( buffer->Des() );
  3413             iMimeHeaders->SetContentLocationL( buffer->Des() );
  3411             CleanupStack::PopAndDestroy( buffer );
  3414             CleanupStack::PopAndDestroy( buffer );
  3412             buffer = NULL;
  3415             buffer = NULL;
  4377                     iPosition += KMms2;
  4380                     iPosition += KMms2;
  4378                     start += KMms2; // skip the endianness byte from the subject
  4381                     start += KMms2; // skip the endianness byte from the subject
  4379                     }
  4382                     }
  4380                 else
  4383                 else
  4381                     {
  4384                     {
  4382                     CBufFlat* shortBuffer = CBufFlat::NewL( KMms2 );
  4385                     // coverity[size_error][buffer_alloc]
       
  4386 					CBufFlat* shortBuffer = CBufFlat::NewL( KMms2 );
  4383                     CleanupStack::PushL( shortBuffer );
  4387                     CleanupStack::PushL( shortBuffer );
  4384                     shortBuffer->ResizeL( KMms2 );
  4388                     shortBuffer->ResizeL( KMms2 );
  4385                     // no need to put it into cleanupstack... we don't leave before we delete it
  4389                     // no need to put it into cleanupstack... we don't leave before we delete it
  4386                     TUint8 byte;
  4390                     TUint8 byte;
  4387                     // put little-endian BOM to buffer
  4391                     // put little-endian BOM to buffer
  6295         // If there is data following a corrupted header, it will be lost.
  6299         // If there is data following a corrupted header, it will be lost.
  6296         size = iLength - iPosition;
  6300         size = iLength - iPosition;
  6297         }
  6301         }
  6298     TUint endPosition = iPosition + size;
  6302     TUint endPosition = iPosition + size;
  6299     HBufC16* buffer = NULL;
  6303     HBufC16* buffer = NULL;
  6300     buffer = GetSimpleTextStringL(); // I hope this is correct.
  6304     // coverity[size_error][buffer_alloc]
       
  6305 	buffer = GetSimpleTextStringL(); // I hope this is correct.
  6301     CleanupStack::PushL( buffer );
  6306     CleanupStack::PushL( buffer );
  6302     iMmsHeaders->ElementDescriptorL().SetContentReferenceL( buffer->Des() );
  6307     iMmsHeaders->ElementDescriptorL().SetContentReferenceL( buffer->Des() );
  6303 #ifndef _NO_MMSS_LOGGING_
  6308 #ifndef _NO_MMSS_LOGGING_
  6304     dummy.Set( buffer->Des().Left( KMmsMaxLogStringLength ) );
  6309     dummy.Set( buffer->Des().Left( KMmsMaxLogStringLength ) );
  6305     TMmsLogger::Log( _L("- Content reference: %S"), &dummy );
  6310     TMmsLogger::Log( _L("- Content reference: %S"), &dummy );
  6354     {
  6359     {
  6355     TPtrC8 byteString;
  6360     TPtrC8 byteString;
  6356     HBufC16* buffer = NULL;
  6361     HBufC16* buffer = NULL;
  6357     byteString.Set( GetUtf8String() );
  6362     byteString.Set( GetUtf8String() );
  6358     // There will be at most one unicode character per one utf-8 character
  6363     // There will be at most one unicode character per one utf-8 character
       
  6364 	// coverity[incorrect_multiplication][buffer_alloc]
  6359     buffer = HBufC16::NewL( byteString.Length() * KMms2 );
  6365     buffer = HBufC16::NewL( byteString.Length() * KMms2 );
  6360     TPtr16 pointer16 = buffer->Des();
  6366     TPtr16 pointer16 = buffer->Des();
  6361     CleanupStack::PushL( buffer );
  6367     CleanupStack::PushL( buffer );
  6362     // We convert what we can and forget the rest.
  6368     // We convert what we can and forget the rest.
  6363     CnvUtfConverter::ConvertToUnicodeFromUtf8( pointer16, byteString );
  6369     CnvUtfConverter::ConvertToUnicodeFromUtf8( pointer16, byteString );
  6376 //
  6382 //
  6377 // ---------------------------------------------------------
  6383 // ---------------------------------------------------------
  6378 void CMmsDecode::DecodeExtNotifEolL()
  6384 void CMmsDecode::DecodeExtNotifEolL()
  6379     {
  6385     {
  6380     HBufC16* buffer = NULL;
  6386     HBufC16* buffer = NULL;
  6381     buffer = GetSimpleTextStringL();
  6387 	// coverity[size_error][buffer_alloc]
       
  6388 	buffer = GetSimpleTextStringL();
  6382     CleanupStack::PushL( buffer );
  6389     CleanupStack::PushL( buffer );
  6383     iMmsHeaders->SetMessageComplete( ( buffer->Des() )[0] );
  6390     iMmsHeaders->SetMessageComplete( ( buffer->Des() )[0] );
  6384 #ifndef _NO_MMSS_LOGGING_
  6391 #ifndef _NO_MMSS_LOGGING_
  6385     TUint temp;
  6392     TUint temp;
  6386     temp = ( buffer->Des() )[0];
  6393     temp = ( buffer->Des() )[0];
  6472 // ---------------------------------------------------------
  6479 // ---------------------------------------------------------
  6473 //
  6480 //
  6474 void CMmsDecode::DecodeApplicationIdL()
  6481 void CMmsDecode::DecodeApplicationIdL()
  6475     {
  6482     {
  6476     HBufC16* buffer = NULL;
  6483     HBufC16* buffer = NULL;
       
  6484 	
       
  6485 	// coverity[size_error][buffer_alloc]
  6477     buffer = GetSimpleTextStringL();
  6486     buffer = GetSimpleTextStringL();
  6478     CleanupStack::PushL( buffer );
  6487     CleanupStack::PushL( buffer );
  6479     iMmsHeaders->SetApplicIdL( buffer->Des() );
  6488     iMmsHeaders->SetApplicIdL( buffer->Des() );
  6480 #ifndef _NO_MMSS_LOGGING_
  6489 #ifndef _NO_MMSS_LOGGING_
  6481     TPtrC dummy;
  6490     TPtrC dummy;
  6490 // ---------------------------------------------------------
  6499 // ---------------------------------------------------------
  6491 //
  6500 //
  6492 void CMmsDecode::DecodeReplyApplicationIdL()
  6501 void CMmsDecode::DecodeReplyApplicationIdL()
  6493     {
  6502     {
  6494     HBufC16* buffer = NULL;
  6503     HBufC16* buffer = NULL;
  6495     buffer = GetSimpleTextStringL();
  6504 	
       
  6505 	// coverity[size_error][buffer_alloc]
       
  6506 	buffer = GetSimpleTextStringL();
  6496     CleanupStack::PushL( buffer );
  6507     CleanupStack::PushL( buffer );
  6497     iMmsHeaders->SetReplyApplicIdL( buffer->Des() );
  6508     iMmsHeaders->SetReplyApplicIdL( buffer->Des() );
  6498 #ifndef _NO_MMSS_LOGGING_
  6509 #ifndef _NO_MMSS_LOGGING_
  6499     TPtrC dummy;
  6510     TPtrC dummy;
  6500     dummy.Set( buffer->Des().Left( KMmsMaxLogStringLength ) );
  6511     dummy.Set( buffer->Des().Left( KMmsMaxLogStringLength ) );