summaryrefslogtreecommitdiff
path: root/ssdv.c
diff options
context:
space:
mode:
authorPhilip Heron <phil@sanslogic.co.uk>2012-02-27 21:37:10 +0000
committerPhilip Heron <phil@sanslogic.co.uk>2012-02-27 21:37:10 +0000
commitb1b314cdfcea8aced040ffec8c09cb6ab89f1a6d (patch)
tree7dc9497714342adc678c7907ed6be0982eea97b4 /ssdv.c
parent87c302a878a6d925f1dffb8ec93ae38ccc6019e7 (diff)
Check for too many MCU blocks in source image
Diffstat (limited to 'ssdv.c')
-rw-r--r--ssdv.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/ssdv.c b/ssdv.c
index 9741491..1990863 100644
--- a/ssdv.c
+++ b/ssdv.c
@@ -689,13 +689,21 @@ static char ssdv_have_marker_data(ssdv_t *s)
/* Calculate number of MCU blocks in this image */
switch(s->mcu_mode)
{
- case 0: s->mcu_count = (s->width >> 4) * (s->height >> 4); break;
- case 1: s->mcu_count = (s->width >> 4) * (s->height >> 3); break;
- case 2: s->mcu_count = (s->width >> 3) * (s->height >> 4); break;
- case 3: s->mcu_count = (s->width >> 3) * (s->height >> 3); break;
+ case 0: l = (s->width >> 4) * (s->height >> 4); break;
+ case 1: l = (s->width >> 4) * (s->height >> 3); break;
+ case 2: l = (s->width >> 3) * (s->height >> 4); break;
+ case 3: l = (s->width >> 3) * (s->height >> 3); break;
}
- fprintf(stderr, "MCU blocks: %i\n", s->mcu_count);
+ fprintf(stderr, "MCU blocks: %i\n", l);
+
+ if(l > 0xFFFF)
+ {
+ fprintf(stderr, "Error: Maximum number of MCU blocks is 65535\n");
+ return(SSDV_ERROR);
+ }
+
+ s->mcu_count = l;
break;