add boundary checks for RATIONAL and SRATIONAL generic output (oss-fuzz)

This commit is contained in:
Marcus Meissner
2021-08-25 13:14:37 +02:00
parent 4d43784686
commit bc279f31a1
+4
View File
@@ -132,12 +132,16 @@ mnote_apple_entry_get_value(MnoteAppleEntry *entry, char *v, unsigned int maxlen
}
break;
case EXIF_FORMAT_RATIONAL:
if (size < exif_format_get_size (EXIF_FORMAT_RATIONAL)) return NULL;
if (entry->components < 1) return NULL; /* FIXME: could handle more than 1 too */
vr = exif_get_rational (data, entry->order);
if (!vr.denominator) break;
snprintf (v, maxlen, "%2.4f", (double) vr.numerator /
vr.denominator);
break;
case EXIF_FORMAT_SRATIONAL:
if (size < exif_format_get_size (EXIF_FORMAT_SRATIONAL)) return NULL;
if (entry->components < 1) return NULL; /* FIXME: could handle more than 1 too */
vsr = exif_get_srational (data, entry->order);
if (!vsr.denominator) break;
snprintf (v, maxlen, "%2.4f", (double) vsr.numerator /