check filelist vs index size

This commit is contained in:
Marcus Meissner
2019-04-27 19:53:41 +02:00
parent 560e15d3f4
commit 5ed748716c
2 changed files with 10 additions and 2 deletions

View File

@@ -152,7 +152,7 @@ pccam300_get_file (GPPort *port, GPContext *context, int index,
unsigned char **data, unsigned int *size,
unsigned int *type)
{
unsigned int data_size;
unsigned int data_size, alloc_size;
int r;
uint8_t *buf = NULL;
@@ -166,7 +166,10 @@ pccam300_get_file (GPPort *port, GPContext *context, int index,
* bytes long. The first 0x200 bytes of the data appear to be
* garbage, they are overwritten by the header. */
*size = data_size + 623 - 0x200;
if (!(buf = malloc (*size)))
alloc_size = *size;
if (alloc_size < 623) alloc_size = 623;
if (!(buf = malloc (alloc_size)))
return GP_ERROR_NO_MEMORY;
/* Read the data into the buffer overlapping the header area by

View File

@@ -313,6 +313,11 @@ int tiger_get_file_list(CameraPrivateLibrary *dev) {
if (ret < 0) {
goto list_files_error;
}
if (ret < buflen) {
GP_DEBUG("Read only %i instead of %i!", buflen, ret);
ret=GP_ERROR_NO_MEMORY;
goto list_files_error;
}
if (dev->file_list) free(dev->file_list);