提交 850a198f 编写于 作者: M Mark Adler

Avoid use of Z_BUF_ERROR in gz* functions except for premature EOF.

Z_BUF_ERROR was also being used for an unsuccessful gzungetc and for buffer
lengths that didn't fit in an int.  Those uses were changed to Z_DATA_ERROR
in order to assure that Z_BUF_ERROR occurs only when a premature end of
input occurs, indicating that gzclearerr() can be used.
上级 377173b5
...@@ -302,7 +302,7 @@ int ZEXPORT gzread(file, buf, len) ...@@ -302,7 +302,7 @@ int ZEXPORT gzread(file, buf, len)
/* since an int is returned, make sure len fits in one, otherwise return /* since an int is returned, make sure len fits in one, otherwise return
with an error (this avoids the flaw in the interface) */ with an error (this avoids the flaw in the interface) */
if ((int)len < 0) { if ((int)len < 0) {
gz_error(state, Z_BUF_ERROR, "requested length does not fit in int"); gz_error(state, Z_DATA_ERROR, "requested length does not fit in int");
return -1; return -1;
} }
...@@ -445,7 +445,7 @@ int ZEXPORT gzungetc(c, file) ...@@ -445,7 +445,7 @@ int ZEXPORT gzungetc(c, file)
/* if no room, give up (must have already done a gzungetc()) */ /* if no room, give up (must have already done a gzungetc()) */
if (state->x.have == (state->size << 1)) { if (state->x.have == (state->size << 1)) {
gz_error(state, Z_BUF_ERROR, "out of room to push characters"); gz_error(state, Z_DATA_ERROR, "out of room to push characters");
return -1; return -1;
} }
......
...@@ -185,7 +185,7 @@ int ZEXPORT gzwrite(file, buf, len) ...@@ -185,7 +185,7 @@ int ZEXPORT gzwrite(file, buf, len)
/* since an int is returned, make sure len fits in one, otherwise return /* since an int is returned, make sure len fits in one, otherwise return
with an error (this avoids the flaw in the interface) */ with an error (this avoids the flaw in the interface) */
if ((int)len < 0) { if ((int)len < 0) {
gz_error(state, Z_BUF_ERROR, "requested length does not fit in int"); gz_error(state, Z_DATA_ERROR, "requested length does not fit in int");
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册