Skip to content
Snippets Groups Projects
Commit 90287635 authored by Mark Adler's avatar Mark Adler
Browse files

Return an error if the gzputs string length can't fit in an int.

parent 60a5ecc6
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -353,8 +353,7 @@ int ZEXPORT gzputs(file, str)
gzFile file;
const char *str;
{
int ret;
z_size_t len;
z_size_t len, put;
gz_statep state;
 
/* get internal structure */
Loading
Loading
@@ -368,8 +367,12 @@ int ZEXPORT gzputs(file, str)
 
/* write string */
len = strlen(str);
ret = gz_write(state, str, len);
return ret == 0 && len != 0 ? -1 : ret;
if ((int)len < 0 || (unsigned)len != len) {
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)
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment