check filelist vs index size
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user