handle non-0 terminated value returns as failure
authorMarcus Meissner <marcus@jet.franken.de>
Sat, 2 Feb 2019 18:04:59 +0000 (19:04 +0100)
committerMarcus Meissner <marcus@jet.franken.de>
Sat, 2 Feb 2019 18:05:25 +0000 (19:05 +0100)
test/test-fuzzer.c

index d72f6d1..2af7288 100644 (file)
 void content_foreach_func(ExifEntry *entry, void *callback_data);
 void content_foreach_func(ExifEntry *entry, void *UNUSED(callback_data))
 {
-       char buf[2000];
+       char buf[2001];
 
-       exif_entry_get_value(entry, buf, sizeof(buf));
+       /* ensure \0 */
+       buf[sizeof(buf)-1] = 0;
+       buf[sizeof(buf)-2] = 0;
+       exif_entry_get_value(entry, buf, sizeof(buf)-1);
        printf("    Entry %p: %s (%s)\n"
                 "      Size, Comps: %d, %d\n"
                 "      Value: %s\n", 
@@ -45,7 +48,8 @@ void content_foreach_func(ExifEntry *entry, void *UNUSED(callback_data))
                 exif_format_get_name(entry->format),
                 entry->size,
                 (int)(entry->components),
-                exif_entry_get_value(entry, buf, sizeof(buf)));
+                exif_entry_get_value(entry, buf, sizeof(buf)-1));
+       if (buf[sizeof(buf)-2] != 0) abort();
 }