Skip to content

Commit

Permalink
Fixed a MIFF decoding bug (buffer overrun when "depth" param is missing)
Browse files Browse the repository at this point in the history
Fixes issue #12
  • Loading branch information
jsummers committed Apr 5, 2017
1 parent 4500070 commit f9c12fa
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/imagew-miff.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ static int iwmiff_read_pixels(struct iwmiffrcontext *rctx)
if(rctx->miff_bitdepth==64) {
iwmiffr_convert_row64_32(rctx,tmprow,&img->pixels[j*img->bpr],samples_per_row);
}
else {
else if(rctx->miff_bitdepth==32) {
iwmiffr_convert_row32(rctx,tmprow,&img->pixels[j*img->bpr],samples_per_row);
}
}
Expand Down Expand Up @@ -551,6 +551,12 @@ IW_IMPL(int) iw_read_miff_file(struct iw_context *ctx, struct iw_iodescr *iodesc
if(!iwmiff_read_header(&rctx))
goto done;

if(img.bit_depth!=32 && img.bit_depth!=64) {
iw_set_error(ctx, "MIFF: Unsupported or unset bit depth");
goto done;

}

if(!iw_check_image_dimensions(rctx.ctx,img.width,img.height))
goto done;

Expand Down

0 comments on commit f9c12fa

Please sign in to comment.