@@ -2682,7 +2682,7 @@ unsafe fn gzrewind_help(state: &mut GzState) -> c_int {
26822682 0
26832683}
26842684
2685- /// Convert, format, compress, and write the variadic arguments `...` to a file under control of the string format, as in `fprintf `.
2685+ /// Convert, format, compress, and write the variadic arguments `...` to a file under control of the string format, as in `printf `.
26862686///
26872687/// # Returns
26882688///
@@ -2707,7 +2707,23 @@ pub unsafe extern "C-unwind" fn gzprintf(
27072707 unsafe { gzvprintf ( file, format, va. as_va_list ( ) ) }
27082708}
27092709
2710+ /// Convert, format, compress, and write the variable argument list to a file under control of the string format, as in `vprintf`.
2711+ ///
2712+ /// # Returns
2713+ ///
2714+ /// Returns the number of uncompressed bytes actually written, or a negative zlib error code in case of error.
2715+ /// The number of uncompressed bytes written is limited to 8191, or one less than the buffer size given to [`gzbuffer`].
2716+ /// The caller should assure that this limit is not exceeded. If it is exceeded, then [`gzvprintf`] will return `0` with nothing written.
2717+ ///
2718+ /// Contrary to other implementations that can use the insecure `vsprintf`, the `zlib-rs` library always uses `vsnprintf`,
2719+ /// so attempting to write more bytes than the limit can never run into buffer overflow issues.
2720+ ///
2721+ /// # Safety
2722+ ///
2723+ /// - The `format` must be a valid C string
2724+ /// - The variadic arguments must correspond with the format string in number and type
27102725#[ cfg( feature = "gzprintf" ) ]
2726+ #[ export_name = crate :: prefix!( gzvprintf) ]
27112727unsafe extern "C-unwind" fn gzvprintf (
27122728 file : gzFile ,
27132729 format : * const c_char ,
0 commit comments