1 Star 0 Fork 20

桐小哥/exiv2

forked from src-openEuler/exiv2 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
CVE-2018-11037.patch 1.63 KB
一键复制 编辑 原始数据 按行查看 历史
Vchanger 提交于 2020-04-16 10:28 . exiv2: fix CVE-2018-11037
From e40c9c148e4d2135d0d732b8dff994a9afde3394 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dan=20=C4=8Cerm=C3=A1k?= <dan.cermak@cgc-instruments.com>
Date: Fri, 6 Jul 2018 11:51:55 +0200
Subject: [PATCH] Remove buffer overread in tExtToDataBuf
The pointer p is advanced in the while loop to step over three '\n'.
However, its length is never reduced accordingly. => the length check in the
following for loop is invalid, as it permits overreading by the number of
characters that p was advanced by.
---
src/pngimage.cpp | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/src/pngimage.cpp b/src/pngimage.cpp
index dc623c4..a99a20b 100644
--- a/src/pngimage.cpp
+++ b/src/pngimage.cpp
@@ -160,12 +160,21 @@ namespace Exiv2 {
}
// calculate length and allocate result;
+ // count: number of \n in the header
long count=0;
+ // p points to the current position in the array bytes
const byte* p = bytes ;
- // header is \nsomething\n number\n hex
- while ( count < 3 )
- if ( *p++ == '\n' )
+
+ // header is '\nsomething\n number\n hex'
+ // => increment p until it points to the byte after the last \n
+ // p must stay within bounds of the bytes array!
+ while ((count < 3) && (p - bytes < length)) {
+ // length is later used for range checks of p => decrement it for each increment of p
+ --length;
+ if ( *p++ == '\n' ) {
count++;
+ }
+ }
for ( long i = 0 ; i < length ; i++ )
if ( value[p[i]] )
++count;
--
1.8.3.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/tong_1001/exiv2.git
git@gitee.com:tong_1001/exiv2.git
tong_1001
exiv2
exiv2
master

搜索帮助