handle partial read files, avoid crashes (AFL)

This commit is contained in:
Marcus Meissner
2020-02-01 18:24:23 +01:00
parent 409b88262c
commit 2ddf19764d
2 changed files with 5 additions and 1 deletions

View File

@@ -330,7 +330,10 @@ file_list_func (CameraFilesystem *fs, const char *folder,
CHECK (spca50x_sdram_get_info (camera->pl));
for (i = 0; i < camera->pl->num_files_on_sdram; i++) {
strncpy (temp_file, camera->pl->files[i].name, 12);
if (camera->pl->files[i].name)
strncpy (temp_file, camera->pl->files[i].name, 12);
else
strcpy (temp_file, "BAD.BAD");
temp_file[12] = 0;
gp_list_append (list, temp_file, NULL);
}

View File

@@ -226,6 +226,7 @@ spca50x_get_image (CameraPrivateLibrary * lib, uint8_t ** buf,
int omit_escape = 0;
p = g_file->fat;
if (!p) return GP_ERROR;
/* get the position in memory where the image is */
start = (p[1] & 0xff) + (p[2] & 0xff) * 0x100;