Fix SVACE issue 50/224250/1
authorSeoyeon Kim <seoyeon2.kim@samsung.com>
Fri, 7 Feb 2020 07:19:51 +0000 (16:19 +0900)
committerSeoyeon Kim <seoyeon2.kim@samsung.com>
Fri, 7 Feb 2020 07:22:41 +0000 (16:22 +0900)
- Integer overflow may occur due to arithmetic operation.
  : fileHeader.zsize is unsigned char[], and zDepth is unsigned int

Change-Id: I9fbd76a1e8f52933a50ae4b014ec361db3a6babf
Signed-off-by: Seoyeon Kim <seoyeon2.kim@samsung.com>
dali/internal/imaging/common/loader-astc.cpp

index 4765bf9..1371a65 100755 (executable)
@@ -138,7 +138,9 @@ bool LoadAstcHeader( FILE * const filePointer, unsigned int& width, unsigned int
   width = fileHeader.xsize[0] | ( fileHeader.xsize[1] << 8 ) | ( fileHeader.xsize[2] << 16 );
   height = fileHeader.ysize[0] | ( fileHeader.ysize[1] << 8 ) | ( fileHeader.ysize[2] << 16 );
 
-  const unsigned int zDepth = fileHeader.zsize[0] + ( fileHeader.zsize[1] << 8 ) + ( fileHeader.zsize[2] << 16 );
+  const unsigned int zDepth = static_cast<unsigned int>( fileHeader.zsize[0] )
+                              + ( static_cast<unsigned int>( fileHeader.zsize[1] ) << 8 )
+                              + ( static_cast<unsigned int>( fileHeader.zsize[2] ) << 16 );
 
   // Check image dimensions are within limits.
   if( ( width > MAX_TEXTURE_DIMENSION ) || ( height > MAX_TEXTURE_DIMENSION ) )