Merge pull request #4 from DL7AD/patch_check_for_invalid_marker

Added exception for corrupt marker data
This commit is contained in:
Philip Heron 2021-09-20 19:47:03 +01:00 committed by GitHub
commit 3f60ec89e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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;