Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Libpng
提交
ddabd0c7
T
Third Party Libpng
项目概览
OpenHarmony
/
Third Party Libpng
大约 1 年 前同步成功
通知
4
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Libpng
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ddabd0c7
编写于
8月 21, 2017
作者:
G
Glenn Randers-Pehrson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[libpng16] Added contrib/oss-fuzz directory
上级
94575916
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
162 addition
and
1 deletion
+162
-1
ANNOUNCE
ANNOUNCE
+5
-1
CHANGES
CHANGES
+4
-0
contrib/oss-fuzz/README.txt
contrib/oss-fuzz/README.txt
+3
-0
contrib/oss-fuzz/libpng_read_fuzzer.cc
contrib/oss-fuzz/libpng_read_fuzzer.cc
+150
-0
未找到文件。
ANNOUNCE
浏览文件 @
ddabd0c7
Libpng 1.6.32rc01 - August
18
, 2017
Libpng 1.6.32rc01 - August
22
, 2017
This is not intended to be a public release. It will be replaced
within a few weeks by a public version or by another test version.
...
...
@@ -104,6 +104,10 @@ Version 1.6.32rc01 [August 18, 2017]
names differ only in case; this causes problems with some platforms
(github issue #172).
Version 1.6.32rc02 [August 22, 2017]
Added contrib/oss-fuzz directory which contains a target for the oss-fuzz
project.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
...
...
CHANGES
浏览文件 @
ddabd0c7
...
...
@@ -5987,6 +5987,10 @@ Version 1.6.32rc01 [August 18, 2017]
names differ only in case; this causes problems with some platforms
(github issue #172).
Version 1.6.32rc02 [August 22, 2017]
Added contrib/oss-fuzz directory which contains a target for the oss-fuzz
project.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
...
...
contrib/oss-fuzz/README.txt
0 → 100644
浏览文件 @
ddabd0c7
Files in this directory are used by the oss-fuzz target for "fuzzing libpng.
They were originally licensed by google inc, using the Apache-2.0 license,
which may be found at https://www.apache.org/licenses/LICENSE-2.0.
contrib/oss-fuzz/libpng_read_fuzzer.cc
0 → 100644
浏览文件 @
ddabd0c7
// libpng_read_fuzzer.cc
// Copyright 2017 Glenn Randers-Pehrson
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that could
// previously be found in a LICENSE file.
// The modifications by Glenn Randers-Pehrson include the addition of a
// PNG_CLEANUP macro and setting the option to ignore ADLER32 checksums.
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <vector>
#define PNG_INTERNAL
#include "png.h"
#define PNG_CLEANUP \
if(png_handler.png_ptr) \
{ \
if (png_handler.info_ptr) \
png_destroy_read_struct(&png_handler.png_ptr, &png_handler.info_ptr,\
nullptr); \
else \
png_destroy_read_struct(&png_handler.png_ptr, nullptr, nullptr); \
}
struct
BufState
{
const
uint8_t
*
data
;
size_t
bytes_left
;
};
struct
PngObjectHandler
{
png_infop
info_ptr
=
nullptr
;
png_structp
png_ptr
=
nullptr
;
png_voidp
row_ptr
=
nullptr
;
BufState
*
buf_state
=
nullptr
;
~
PngObjectHandler
()
{
if
(
row_ptr
&&
png_ptr
)
{
png_free
(
png_ptr
,
row_ptr
);
}
if
(
png_ptr
&&
info_ptr
)
{
png_destroy_read_struct
(
&
png_ptr
,
&
info_ptr
,
nullptr
);
}
delete
buf_state
;
}
};
void
user_read_data
(
png_structp
png_ptr
,
png_bytep
data
,
png_size_t
length
)
{
BufState
*
buf_state
=
static_cast
<
BufState
*>
(
png_get_io_ptr
(
png_ptr
));
if
(
length
>
buf_state
->
bytes_left
)
{
png_error
(
png_ptr
,
"read error"
);
}
memcpy
(
data
,
buf_state
->
data
,
length
);
buf_state
->
bytes_left
-=
length
;
buf_state
->
data
+=
length
;
}
static
const
int
kPngHeaderSize
=
8
;
// Entry point for LibFuzzer.
// Roughly follows the libpng book example:
// http://www.libpng.org/pub/png/book/chapter13.html
extern
"C"
int
LLVMFuzzerTestOneInput
(
const
uint8_t
*
data
,
size_t
size
)
{
if
(
size
<
kPngHeaderSize
)
{
return
0
;
}
std
::
vector
<
unsigned
char
>
v
(
data
,
data
+
size
);
if
(
png_sig_cmp
(
v
.
data
(),
0
,
kPngHeaderSize
))
{
// not a PNG.
return
0
;
}
PngObjectHandler
png_handler
;
png_handler
.
png_ptr
=
png_create_read_struct
(
PNG_LIBPNG_VER_STRING
,
nullptr
,
nullptr
,
nullptr
);
if
(
!
png_handler
.
png_ptr
)
{
return
0
;
}
png_handler
.
info_ptr
=
png_create_info_struct
(
png_handler
.
png_ptr
);
if
(
!
png_handler
.
info_ptr
)
{
PNG_CLEANUP
return
0
;
}
png_set_crc_action
(
png_handler
.
png_ptr
,
PNG_CRC_QUIET_USE
,
PNG_CRC_QUIET_USE
);
#ifdef PNG_IGNORE_ADLER32
png_set_option
(
read_ptr
,
PNG_IGNORE_ADLER32
,
PNG_OPTION_ON
);
#endif
// Setting up reading from buffer.
png_handler
.
buf_state
=
new
BufState
();
png_handler
.
buf_state
->
data
=
data
+
kPngHeaderSize
;
png_handler
.
buf_state
->
bytes_left
=
size
-
kPngHeaderSize
;
png_set_read_fn
(
png_handler
.
png_ptr
,
png_handler
.
buf_state
,
user_read_data
);
png_set_sig_bytes
(
png_handler
.
png_ptr
,
kPngHeaderSize
);
if
(
setjmp
(
png_jmpbuf
(
png_handler
.
png_ptr
)))
{
PNG_CLEANUP
return
0
;
}
// Reading.
png_read_info
(
png_handler
.
png_ptr
,
png_handler
.
info_ptr
);
png_handler
.
row_ptr
=
png_malloc
(
png_handler
.
png_ptr
,
png_get_rowbytes
(
png_handler
.
png_ptr
,
png_handler
.
info_ptr
));
// reset error handler to put png_deleter into scope.
if
(
setjmp
(
png_jmpbuf
(
png_handler
.
png_ptr
)))
{
PNG_CLEANUP
return
0
;
}
png_uint_32
width
,
height
;
int
bit_depth
,
color_type
,
interlace_type
,
compression_type
;
int
filter_type
;
if
(
!
png_get_IHDR
(
png_handler
.
png_ptr
,
png_handler
.
info_ptr
,
&
width
,
&
height
,
&
bit_depth
,
&
color_type
,
&
interlace_type
,
&
compression_type
,
&
filter_type
))
{
PNG_CLEANUP
return
0
;
}
// This is going to be too slow.
if
(
width
&&
height
>
100000000
/
width
)
{
PNG_CLEANUP
return
0
;
}
int
passes
=
png_set_interlace_handling
(
png_handler
.
png_ptr
);
png_start_read_image
(
png_handler
.
png_ptr
);
for
(
int
pass
=
0
;
pass
<
passes
;
++
pass
)
{
for
(
png_uint_32
y
=
0
;
y
<
height
;
++
y
)
{
png_read_row
(
png_handler
.
png_ptr
,
static_cast
<
png_bytep
>
(
png_handler
.
row_ptr
),
nullptr
);
}
}
PNG_CLEANUP
return
0
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录