]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[xferbuf] Silently discard data written to a void data transfer buffer
authorMichael Brown <mcb30@ipxe.org>
Wed, 25 Feb 2026 00:14:26 +0000 (00:14 +0000)
committerMichael Brown <mcb30@ipxe.org>
Wed, 25 Feb 2026 00:19:20 +0000 (00:19 +0000)
Allow data to be successfully written (and discarded) to a void data
transfer buffer, rather than throwing an error.  This allows a void
data transfer buffer to be used when determining the length of a file
downloaded from a TFTP server that does not support the "tsize" option
defined in RFC 2349.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/core/xferbuf.c

index a313c625ae105482f86f2910adfbb22970422b15..424de41677b6393f198654a5ffeb45c0720a9110 100644 (file)
@@ -129,13 +129,10 @@ int xferbuf_write ( struct xfer_buffer *xferbuf, size_t offset,
        if ( ( rc = xferbuf_ensure_size ( xferbuf, max_len ) ) != 0 )
                return rc;
 
-       /* Check that buffer is non-void */
-       if ( len && ( ! xferbuf->data ) )
-               return -ENOTTY;
-
-       /* Copy data to buffer */
+       /* Copy data to buffer (if non-void) */
        profile_start ( &xferbuf_write_profiler );
-       memcpy ( ( xferbuf->data + offset ), data, len );
+       if ( xferbuf->data )
+               memcpy ( ( xferbuf->data + offset ), data, len );
        profile_stop ( &xferbuf_write_profiler );
 
        return 0;