com php-src: Fix bug #68283: fileinfo: out-of-bounds read in elf note headers: ext/fileinfo/libmagic/readelf.c
| From: | Remi Collet | Date: | Sat, 25 Oct 2014 09:29:16 +0000 |
| Subject: | com php-src: Fix bug #68283: fileinfo: out-of-bounds read in elf note headers: ext/fileinfo/libmagic/readelf.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-82654@lists.php.net to get a copy of this message | ||
Commit: 5b295bf19161b14d6c81151fd89c2f17bd50525c
Author: Remi Collet <remi@php.net> Wed, 22 Oct 2014 15:37:04 +0200
Parents: 37d5a2b18febc07088b15f06c6e5cc73eca782a0
Branches: PHP-5.5 PHP-5.6 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=5b295bf19161b14d6c81151fd89c2f17bd50525c
Log:
Fix bug #68283: fileinfo: out-of-bounds read in elf note headers
Upstream commit
https://github..com/file/file/commit/39c7ac1106be844a5296d3eb5971946cc09ffda0
CVE -2014-3710
(cherry picked from commit 1803228597e82218a8c105e67975bc50e6f5bf0d)
Bugs:
https://bugs.php.net/68283
Changed paths:
M ext/fileinfo/libmagic/readelf.c
Diff:
diff --git a/ext/fileinfo/libmagic/readelf.c b/ext/fileinfo/libmagic/readelf.c
index 1c3845f..bb6f70f 100644
--- a/ext/fileinfo/libmagic/readelf.c
+++ b/ext/fileinfo/libmagic/readelf.c
@@ -372,6 +372,13 @@ donote(struct magic_set *ms, void *vbuf, size_t offset, size_t size,
uint32_t namesz, descsz;
unsigned char *nbuf = CAST(unsigned char *, vbuf);
+ if (xnh_sizeof + offset > size) {
+ /*
+ * We're out of note headers.
+ */
+ return xnh_sizeof + offset;
+ }
+
(void)memcpy(xnh_addr, &nbuf[offset], xnh_sizeof);
offset += xnh_sizeof;