Skip to content

Commit f999a37

Browse files
authored
PR #14430 from Nir-Az: Protect jpeg unpack
2 parents 5a34219 + 807529d commit f999a37

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/proc/color-formats-converter.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1090,11 +1090,17 @@ namespace librealsense
10901090
if (uncompressed_rgb)
10911091
{
10921092
auto uncompressed_size = w * h * bpp;
1093+
if (uncompressed_size != actual_size)
1094+
{
1095+
LOG_WARNING( "MJPEG decode size mismatch. Expected " << actual_size << ", got "
1096+
<< uncompressed_size );
1097+
uncompressed_size = std::min( uncompressed_size, actual_size );
1098+
}
10931099
std::memcpy( dest[0], uncompressed_rgb, uncompressed_size );
10941100
stbi_image_free(uncompressed_rgb);
10951101
}
10961102
else
1097-
LOG_ERROR("jpeg decode failed");
1103+
LOG_ERROR("mjpeg decode failed");
10981104
}
10991105

11001106
/////////////////////////////

0 commit comments

Comments
 (0)