summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Meissner <marcus@jet.franken.de>2020-02-01 18:24:23 +0100
committerMarcus Meissner <marcus@jet.franken.de>2020-02-01 18:24:23 +0100
commit2ddf19764d9f1ddb8beae80d85ce64eedceb9aa4 (patch)
tree98d0cbe09d6bdcc58c4d97a9ea2cdd38d42790d0
parent409b88262c770cf19ff29be3ed6b41b48266b85b (diff)
downloadlibgphoto2-2ddf19764d9f1ddb8beae80d85ce64eedceb9aa4.tar.gz
handle partial read files, avoid crashes (AFL)
-rw-r--r--camlibs/spca50x/library.c5
-rw-r--r--camlibs/spca50x/spca50x-sdram.c1
2 files changed, 5 insertions, 1 deletions
diff --git a/camlibs/spca50x/library.c b/camlibs/spca50x/library.c
index 37487cb8c..93de246b7 100644
--- a/camlibs/spca50x/library.c
+++ b/camlibs/spca50x/library.c
@@ -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);
}
diff --git a/camlibs/spca50x/spca50x-sdram.c b/camlibs/spca50x/spca50x-sdram.c
index f11cc8a32..7a2900008 100644
--- a/camlibs/spca50x/spca50x-sdram.c
+++ b/camlibs/spca50x/spca50x-sdram.c
@@ -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;