diff options
| -rw-r--r-- | gzwrite.c | 11 |
1 files changed, 7 insertions, 4 deletions
| @@ -353,8 +353,7 @@ int ZEXPORT gzputs(file, str) | |||
| 353 | gzFile file; | 353 | gzFile file; |
| 354 | const char *str; | 354 | const char *str; |
| 355 | { | 355 | { |
| 356 | int ret; | 356 | z_size_t len, put; |
| 357 | z_size_t len; | ||
| 358 | gz_statep state; | 357 | gz_statep state; |
| 359 | 358 | ||
| 360 | /* get internal structure */ | 359 | /* get internal structure */ |
| @@ -368,8 +367,12 @@ int ZEXPORT gzputs(file, str) | |||
| 368 | 367 | ||
| 369 | /* write string */ | 368 | /* write string */ |
| 370 | len = strlen(str); | 369 | len = strlen(str); |
| 371 | ret = gz_write(state, str, len); | 370 | if ((int)len < 0 || (unsigned)len != len) { |
| 372 | return ret == 0 && len != 0 ? -1 : ret; | 371 | gz_error(state, Z_STREAM_ERROR, "string length does not fit in int"); |
| 372 | return -1; | ||
| 373 | } | ||
| 374 | put = gz_write(state, str, len); | ||
| 375 | return put < len ? -1 : (int)len; | ||
| 373 | } | 376 | } |
| 374 | 377 | ||
| 375 | #if defined(STDC) || defined(Z_HAVE_STDARG_H) | 378 | #if defined(STDC) || defined(Z_HAVE_STDARG_H) |
