84 LOCAL_C HBufC16* HBuf16FromBlockL( |
84 LOCAL_C HBufC16* HBuf16FromBlockL( |
85 const TDesC8& aBlock, |
85 const TDesC8& aBlock, |
86 TInt aOffset, |
86 TInt aOffset, |
87 TInt aLength ); |
87 TInt aLength ); |
88 |
88 |
|
89 LOCAL_C HBufC16* HBuf16IgnoreNullL( |
|
90 const TDesC8& aBlock, |
|
91 TInt aOffset, |
|
92 TInt aLength ); |
|
93 |
89 LOCAL_C TUint32 ReadUint64FromBlockL( const TDesC8& aBlock, TInt aOffset ) |
94 LOCAL_C TUint32 ReadUint64FromBlockL( const TDesC8& aBlock, TInt aOffset ) |
90 { |
95 { |
91 if ( aBlock.Length() <= ( aOffset + 3 ) ) |
96 if ( aBlock.Length() <= ( aOffset + 3 ) ) |
92 { |
97 { |
93 User::Leave( KErrArgument ); |
98 User::Leave( KErrArgument ); |
136 { |
141 { |
137 ptr.Append( aBlock[aOffset + i] ); |
142 ptr.Append( aBlock[aOffset + i] ); |
138 } |
143 } |
139 |
144 |
140 return buffer; |
145 return buffer; |
|
146 } |
|
147 |
|
148 LOCAL_C HBufC16* HBuf16IgnoreNullL( |
|
149 const TDesC8& aBlock, |
|
150 TInt aOffset, |
|
151 TInt aLength ) |
|
152 { |
|
153 if ( aBlock.Length() < ( aOffset + aLength ) ) |
|
154 { |
|
155 User::Leave( KErrArgument ); |
|
156 } |
|
157 HBufC16* buffer( HBufC16::NewL( aLength / 2 + 1 ) ); |
|
158 TPtr ptr( buffer->Des() ); |
|
159 |
|
160 for ( TInt i( 0 ) ; i < aLength; i+=2 ) |
|
161 { |
|
162 ptr.Append( aBlock[aOffset + i] ); |
|
163 } |
|
164 |
|
165 TInt dLength = ptr.Length(); |
|
166 |
|
167 if ( dLength != 0 && ptr[dLength - 1] == '\0' ) |
|
168 { |
|
169 ptr.SetLength( dLength - 1 ); |
|
170 } |
|
171 |
|
172 return buffer; |
141 } |
173 } |
142 |
174 |
143 // ============================ MEMBER FUNCTIONS =============================== |
175 // ============================ MEMBER FUNCTIONS =============================== |
144 |
176 |
145 // ----------------------------------------------------------------------------- |
177 // ----------------------------------------------------------------------------- |
580 if ( length > objSize - ( KObjectID + KObjectSize + 10 ) ) |
612 if ( length > objSize - ( KObjectID + KObjectSize + 10 ) ) |
581 { |
613 { |
582 User::Leave( KErrOverflow ); |
614 User::Leave( KErrOverflow ); |
583 } |
615 } |
584 |
616 |
585 iTitle = HBuf16FromBlockL( *iHeaderData, offset, iTitleLength ); |
617 iTitle = HBuf16IgnoreNullL( *iHeaderData, offset, iTitleLength ); |
586 offset += iTitleLength; |
618 offset += iTitleLength; |
587 iAuthor = HBuf16FromBlockL( *iHeaderData, offset, iAuthorLength ); |
619 |
|
620 iAuthor = HBuf16IgnoreNullL( *iHeaderData, offset, iAuthorLength ); |
588 offset += iAuthorLength; |
621 offset += iAuthorLength; |
589 iCopyright = HBuf16FromBlockL( *iHeaderData, offset, iCopyrightLength ); |
622 |
|
623 iCopyright = HBuf16IgnoreNullL( *iHeaderData, offset, iCopyrightLength ); |
590 offset += iCopyrightLength; |
624 offset += iCopyrightLength; |
591 iDescription = HBuf16FromBlockL( *iHeaderData, offset, iDescriptionLength ); |
625 |
|
626 iDescription = HBuf16IgnoreNullL( *iHeaderData, offset, iDescriptionLength ); |
592 offset += iDescriptionLength; |
627 offset += iDescriptionLength; |
593 iRating = HBuf16FromBlockL( *iHeaderData, offset, iRatingLength ); |
628 |
|
629 iRating = HBuf16IgnoreNullL( *iHeaderData, offset, iRatingLength ); |
594 offset += iRatingLength; |
630 offset += iRatingLength; |
595 } |
631 } |
596 |
632 |
597 // ----------------------------------------------------------------------------- |
633 // ----------------------------------------------------------------------------- |
598 // CAsf::ParseContentEncryptionObject |
634 // CAsf::ParseContentEncryptionObject |