Added exception for corrupt marker data

This commit is contained in:
Sven Steudte 2021-09-20 19:13:11 +02:00
parent 3122b35260
commit 592a76c1c0
1 changed files with 11 additions and 1 deletions

12
ssdv.c
View File

@ -721,7 +721,7 @@ static char ssdv_have_marker(ssdv_t *s)
static char ssdv_have_marker_data(ssdv_t *s)
{
uint8_t *d = s->marker_data;
size_t l = s->marker_len;
ssize_t l = s->marker_len;
int i;
switch(s->marker)
@ -879,6 +879,11 @@ static char ssdv_have_marker_data(ssdv_t *s)
j += d[i];
l -= j;
if (l < 0)
{
fprintf(stderr, "The image has an invalid marker length\n");
return(SSDV_ERROR);
}
d += j;
}
break;
@ -895,6 +900,11 @@ static char ssdv_have_marker_data(ssdv_t *s)
/* Skip to the next one, if present */
l -= 65;
if (l < 0)
{
fprintf(stderr, "The image has an invalid marker length\n");
return(SSDV_ERROR);
}
d += 65;
}
break;