Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Zlib
提交
bc5503b2
T
Third Party Zlib
项目概览
OpenHarmony
/
Third Party Zlib
接近 2 年 前同步成功
通知
18
Star
112
Fork
2
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Zlib
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
bc5503b2
编写于
1月 02, 2017
作者:
M
Mark Adler
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix bug in deflate_stored() for zero-length input.
上级
52aa5501
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
19 addition
and
18 deletion
+19
-18
deflate.c
deflate.c
+19
-18
未找到文件。
deflate.c
浏览文件 @
bc5503b2
...
@@ -1040,7 +1040,6 @@ int ZEXPORT deflate (strm, flush)
...
@@ -1040,7 +1040,6 @@ int ZEXPORT deflate (strm, flush)
}
}
}
}
}
}
Assert
(
strm
->
avail_out
>
0
,
"bug2"
);
if
(
flush
!=
Z_FINISH
)
return
Z_OK
;
if
(
flush
!=
Z_FINISH
)
return
Z_OK
;
if
(
s
->
wrap
<=
0
)
return
Z_STREAM_END
;
if
(
s
->
wrap
<=
0
)
return
Z_STREAM_END
;
...
@@ -1653,17 +1652,19 @@ local block_state deflate_stored(s, flush)
...
@@ -1653,17 +1652,19 @@ local block_state deflate_stored(s, flush)
* possible. If flushing, copy the remaining available input to next_out as
* possible. If flushing, copy the remaining available input to next_out as
* stored blocks, if there is enough space.
* stored blocks, if there is enough space.
*/
*/
unsigned
len
,
left
,
have
,
last
;
unsigned
len
,
left
,
have
,
last
=
0
;
unsigned
used
=
s
->
strm
->
avail_in
;
unsigned
used
=
s
->
strm
->
avail_in
;
for
(;;)
{
do
{
/* Set len to the maximum size block that we can copy directly with the
/* Set len to the maximum size block that we can copy directly with the
* available input data and output space. Set left to how much of that
* available input data and output space. Set left to how much of that
* would be copied from what's left in the window.
* would be copied from what's left in the window.
*/
*/
len
=
MAX_STORED
;
/* maximum deflate stored block length */
len
=
MAX_STORED
;
/* maximum deflate stored block length */
have
=
(
s
->
bi_valid
+
42
)
>>
3
;
/* number of header bytes */
have
=
(
s
->
bi_valid
+
42
)
>>
3
;
/* number of header bytes */
if
(
s
->
strm
->
avail_out
<
have
)
/* need room for header */
break
;
/* maximum stored block length that will fit in avail_out: */
/* maximum stored block length that will fit in avail_out: */
have
=
s
->
strm
->
avail_out
>
have
?
s
->
strm
->
avail_out
-
have
:
0
;
have
=
s
->
strm
->
avail_out
-
have
;
left
=
s
->
strstart
-
s
->
block_start
;
/* bytes left in window */
left
=
s
->
strstart
-
s
->
block_start
;
/* bytes left in window */
if
(
len
>
(
ulg
)
left
+
s
->
strm
->
avail_in
)
if
(
len
>
(
ulg
)
left
+
s
->
strm
->
avail_in
)
len
=
left
+
s
->
strm
->
avail_in
;
/* limit len to the input */
len
=
left
+
s
->
strm
->
avail_in
;
/* limit len to the input */
...
@@ -1677,7 +1678,8 @@ local block_state deflate_stored(s, flush)
...
@@ -1677,7 +1678,8 @@ local block_state deflate_stored(s, flush)
* copying to the window and the pending buffer instead. Also don't
* copying to the window and the pending buffer instead. Also don't
* write an empty block when flushing -- deflate() does that.
* write an empty block when flushing -- deflate() does that.
*/
*/
if
(
len
<
min_block
&&
(
len
==
0
||
flush
==
Z_NO_FLUSH
||
if
(
len
<
min_block
&&
((
len
==
0
&&
flush
!=
Z_FINISH
)
||
flush
==
Z_NO_FLUSH
||
len
-
left
!=
s
->
strm
->
avail_in
))
len
-
left
!=
s
->
strm
->
avail_in
))
break
;
break
;
...
@@ -1721,7 +1723,7 @@ local block_state deflate_stored(s, flush)
...
@@ -1721,7 +1723,7 @@ local block_state deflate_stored(s, flush)
s
->
strm
->
avail_out
-=
len
;
s
->
strm
->
avail_out
-=
len
;
s
->
strm
->
total_out
+=
len
;
s
->
strm
->
total_out
+=
len
;
}
}
}
}
while
(
last
==
0
);
/* Update the sliding window with the last s->w_size bytes of the copied
/* Update the sliding window with the last s->w_size bytes of the copied
* data, or append all of the copied data to the existing window if less
* data, or append all of the copied data to the existing window if less
...
@@ -1754,13 +1756,14 @@ local block_state deflate_stored(s, flush)
...
@@ -1754,13 +1756,14 @@ local block_state deflate_stored(s, flush)
s
->
insert
+=
MIN
(
used
,
s
->
w_size
-
s
->
insert
);
s
->
insert
+=
MIN
(
used
,
s
->
w_size
-
s
->
insert
);
}
}
/* If flushing or finishing and all input has been consumed, then done. If
/* If the last block was written to next_out, then done. */
* the code above couldn't write a complete block to next_out, then the
if
(
last
)
* code following this won't be able to either.
return
finish_done
;
*/
if
(
flush
!=
Z_NO_FLUSH
&&
s
->
strm
->
avail_in
==
0
&&
/* If flushing and all input has been consumed, then done. */
(
long
)
s
->
strstart
==
s
->
block_start
)
if
(
flush
!=
Z_NO_FLUSH
&&
flush
!=
Z_FINISH
&&
return
flush
==
Z_FINISH
?
finish_done
:
block_done
;
s
->
strm
->
avail_in
==
0
&&
(
long
)
s
->
strstart
==
s
->
block_start
)
return
block_done
;
/* Fill the window with any remaining input. */
/* Fill the window with any remaining input. */
have
=
s
->
window_size
-
s
->
strstart
-
1
;
have
=
s
->
window_size
-
s
->
strstart
-
1
;
...
@@ -1791,20 +1794,18 @@ local block_state deflate_stored(s, flush)
...
@@ -1791,20 +1794,18 @@ local block_state deflate_stored(s, flush)
min_block
=
MIN
(
have
,
s
->
w_size
);
min_block
=
MIN
(
have
,
s
->
w_size
);
left
=
s
->
strstart
-
s
->
block_start
;
left
=
s
->
strstart
-
s
->
block_start
;
if
(
left
>=
min_block
||
if
(
left
>=
min_block
||
(
left
&&
flush
!=
Z_NO_FLUSH
&&
s
->
strm
->
avail_in
==
0
&&
(
(
left
||
flush
==
Z_FINISH
)
&&
flush
!=
Z_NO_FLUSH
&&
left
<=
have
))
{
s
->
strm
->
avail_in
==
0
&&
left
<=
have
))
{
len
=
MIN
(
left
,
have
);
len
=
MIN
(
left
,
have
);
last
=
flush
==
Z_FINISH
&&
s
->
strm
->
avail_in
==
0
&&
last
=
flush
==
Z_FINISH
&&
s
->
strm
->
avail_in
==
0
&&
len
==
left
?
1
:
0
;
len
==
left
?
1
:
0
;
_tr_stored_block
(
s
,
(
charf
*
)
s
->
window
+
s
->
block_start
,
len
,
last
);
_tr_stored_block
(
s
,
(
charf
*
)
s
->
window
+
s
->
block_start
,
len
,
last
);
s
->
block_start
+=
len
;
s
->
block_start
+=
len
;
flush_pending
(
s
->
strm
);
flush_pending
(
s
->
strm
);
if
(
last
)
return
finish_started
;
}
}
/* We've done all we can with the available input and output. */
/* We've done all we can with the available input and output. */
return
need_more
;
return
last
?
finish_started
:
need_more
;
}
}
/* ===========================================================================
/* ===========================================================================
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录