From: Dirk Lemstra Date: Mon, 5 Mar 2018 20:59:16 +0000 (+0100) Subject: Fixed possible undefined shift (https://bugs.chromium.org/p/oss-fuzz/issues/detail... X-Git-Tag: 7.0.7-26~82 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dcfcc5f349bb4f850d85c5e5ba54fa9447b64605;p=imagemagick Fixed possible undefined shift (https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=6337). --- diff --git a/coders/dcm.c b/coders/dcm.c index 00d730485..7de8e5f65 100644 --- a/coders/dcm.c +++ b/coders/dcm.c @@ -2776,7 +2776,8 @@ static int ReadDCMByte(DCMStreamInfo *stream_info,Image *image) static unsigned short ReadDCMShort(DCMStreamInfo *stream_info,Image *image) { int - shift; + shift, + val; unsigned short value; @@ -2784,8 +2785,11 @@ static unsigned short ReadDCMShort(DCMStreamInfo *stream_info,Image *image) if (image->compression != RLECompression) return(ReadBlobLSBShort(image)); shift=image->depth < 16 ? 4 : 8; - value=ReadDCMByte(stream_info,image) | (unsigned short) - (ReadDCMByte(stream_info,image) << shift); + value=ReadDCMByte(stream_info,image); + val=ReadDCMByte(stream_info,image); + if (val < 0) + return(0); + value|=(unsigned short)(val << shift); return(value); }