summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Meissner <marcus@jet.franken.de>2020-05-16 16:47:42 +0200
committerMarcus Meissner <marcus@jet.franken.de>2020-05-16 16:47:42 +0200
commit5ae5973bed1947f4d447dc80b76d5cefadd90133 (patch)
tree2bf28f9c2f59d4d735880fc1893bd5bce246040f
parent154189b77491191e00e1204083ab51c4ad5a60ff (diff)
downloadlibexif-5ae5973bed1947f4d447dc80b76d5cefadd90133.tar.gz
libexif-5ae5973bed1947f4d447dc80b76d5cefadd90133.tar.bz2
libexif-5ae5973bed1947f4d447dc80b76d5cefadd90133.zip
libexif: Fix read buffer overflow (CVE-2020-0093)
Make sure the number of bytes being copied from doesn't exceed the source buffer size. From Android repo: https://android.googlesource.com/platform/external/libexif/+/0335ffc17f9b9a4831c242bb08ea92f605fde7a6%5E%21/#F0 Test: testPocBug_148705132 Bug: 148705132 fixes https://github.com/libexif/libexif/issues/42
-rw-r--r--libexif/exif-data.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/libexif/exif-data.c b/libexif/exif-data.c
index 6332cd1..65ae93d 100644
--- a/libexif/exif-data.c
+++ b/libexif/exif-data.c
@@ -308,7 +308,9 @@ exif_data_save_data_entry (ExifData *data, ExifEntry *e,
/* Write the data. Fill unneeded bytes with 0. Do not crash with
* e->data is NULL */
if (e->data) {
- memcpy (*d + 6 + doff, e->data, s);
+ unsigned int len = s;
+ if (e->size < s) len = e->size;
+ memcpy (*d + 6 + doff, e->data, len);
} else {
memset (*d + 6 + doff, 0, s);
}