From b48965ae5770bbbff04fe1eb3f8a0f0a293ba006 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 25 Feb 2026 00:14:26 +0000 Subject: [PATCH] [xferbuf] Silently discard data written to a void data transfer buffer 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 --- src/core/xferbuf.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/core/xferbuf.c b/src/core/xferbuf.c index a313c625a..424de4167 100644 --- a/src/core/xferbuf.c +++ b/src/core/xferbuf.c @@ -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;