Added exception for corrupt marker data
This commit is contained in:
parent
3122b35260
commit
592a76c1c0
12
ssdv.c
12
ssdv.c
|
@ -721,7 +721,7 @@ static char ssdv_have_marker(ssdv_t *s)
|
||||||
static char ssdv_have_marker_data(ssdv_t *s)
|
static char ssdv_have_marker_data(ssdv_t *s)
|
||||||
{
|
{
|
||||||
uint8_t *d = s->marker_data;
|
uint8_t *d = s->marker_data;
|
||||||
size_t l = s->marker_len;
|
ssize_t l = s->marker_len;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
switch(s->marker)
|
switch(s->marker)
|
||||||
|
@ -879,6 +879,11 @@ static char ssdv_have_marker_data(ssdv_t *s)
|
||||||
j += d[i];
|
j += d[i];
|
||||||
|
|
||||||
l -= j;
|
l -= j;
|
||||||
|
if (l < 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "The image has an invalid marker length\n");
|
||||||
|
return(SSDV_ERROR);
|
||||||
|
}
|
||||||
d += j;
|
d += j;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -895,6 +900,11 @@ static char ssdv_have_marker_data(ssdv_t *s)
|
||||||
|
|
||||||
/* Skip to the next one, if present */
|
/* Skip to the next one, if present */
|
||||||
l -= 65;
|
l -= 65;
|
||||||
|
if (l < 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "The image has an invalid marker length\n");
|
||||||
|
return(SSDV_ERROR);
|
||||||
|
}
|
||||||
d += 65;
|
d += 65;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue