af9dc8
From 1803228597e82218a8c105e67975bc50e6f5bf0d Mon Sep 17 00:00:00 2001
af9dc8
From: Remi Collet <remi@php.net>
af9dc8
Date: Wed, 22 Oct 2014 15:37:04 +0200
af9dc8
Subject: [PATCH] Fix bug #68283: fileinfo: out-of-bounds read in elf note
af9dc8
 headers
af9dc8
af9dc8
Upstream commit
af9dc8
https://github.com/file/file/commit/39c7ac1106be844a5296d3eb5971946cc09ffda0
af9dc8
af9dc8
CVE -2014-3710
af9dc8
---
af9dc8
 ext/fileinfo/libmagic/readelf.c | 7 +++++++
af9dc8
 1 file changed, 7 insertions(+)
af9dc8
af9dc8
diff --git a/ext/fileinfo/libmagic/readelf.c b/ext/fileinfo/libmagic/readelf.c
af9dc8
index 1c3845f..bb6f70f 100644
af9dc8
--- a/ext/fileinfo/libmagic/readelf.c
af9dc8
+++ b/ext/fileinfo/libmagic/readelf.c
af9dc8
@@ -372,6 +372,13 @@ donote(struct magic_set *ms, void *vbuf, size_t offset, size_t size,
af9dc8
 	uint32_t namesz, descsz;
af9dc8
 	unsigned char *nbuf = CAST(unsigned char *, vbuf);
af9dc8
 
af9dc8
+	if (xnh_sizeof + offset > size) {
af9dc8
+		/*
af9dc8
+		 * We're out of note headers.
af9dc8
+		 */
af9dc8
+		return xnh_sizeof + offset;
af9dc8
+	}
af9dc8
+
af9dc8
 	(void)memcpy(xnh_addr, &nbuf[offset], xnh_sizeof);
af9dc8
 	offset += xnh_sizeof;
af9dc8
 
af9dc8
-- 
af9dc8
2.1.0
af9dc8