Return an error if the gzputs string length can't fit in an int.
This commit is contained in:
parent
60a5ecc62b
commit
90287635ef
11
gzwrite.c
11
gzwrite.c
@ -353,8 +353,7 @@ int ZEXPORT gzputs(file, str)
|
|||||||
gzFile file;
|
gzFile file;
|
||||||
const char *str;
|
const char *str;
|
||||||
{
|
{
|
||||||
int ret;
|
z_size_t len, put;
|
||||||
z_size_t len;
|
|
||||||
gz_statep state;
|
gz_statep state;
|
||||||
|
|
||||||
/* get internal structure */
|
/* get internal structure */
|
||||||
@ -368,8 +367,12 @@ int ZEXPORT gzputs(file, str)
|
|||||||
|
|
||||||
/* write string */
|
/* write string */
|
||||||
len = strlen(str);
|
len = strlen(str);
|
||||||
ret = gz_write(state, str, len);
|
if ((int)len < 0 || (unsigned)len != len) {
|
||||||
return ret == 0 && len != 0 ? -1 : ret;
|
gz_error(state, Z_STREAM_ERROR, "string length does not fit in int");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
put = gz_write(state, str, len);
|
||||||
|
return put < len ? -1 : (int)len;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
|
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
|
||||||
|
Loading…
Reference in New Issue
Block a user