This is an automated email from the ASF dual-hosted git repository.
xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new dbcc33f30 netutils/tftpc: Fix NULL dereference when the WRQ is
acknowledged.
dbcc33f30 is described below
commit dbcc33f306e4ba84b881dd62ff9656ea0565b299
Author: raiden00pl <[email protected]>
AuthorDate: Wed Oct 7 16:09:47 2026 +0200
netutils/tftpc: Fix NULL dereference when the WRQ is acknowledged.
tftpput_cb() calls tftp_rcvack() with a NULL blockno for the ACK of
the write request, but tftp_rcvack() always stored the received block
number. On targets where address 0 is not writable (e.g. sim) every
TFTP put crashed.
Store the block number only if the caller asked for it.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: raiden00pl <[email protected]>
---
netutils/tftpc/tftpc_put.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/netutils/tftpc/tftpc_put.c b/netutils/tftpc/tftpc_put.c
index 456100bdb..05d9e03b2 100644
--- a/netutils/tftpc/tftpc_put.c
+++ b/netutils/tftpc/tftpc_put.c
@@ -115,7 +115,8 @@ int tftp_mkdatapacket(off_t offset, FAR uint8_t *packet,
uint16_t blockno,
* packet - buffer to use for the transfers
* server - The address of the server
* port - The port number of the server (0 if not yet known)
- * blockno - Location to return block number in the received ACK
+ * blockno - Location to return block number in the received ACK, or
+ * NULL if the caller does not need it
*
* Returned Value:
* OK:success and blockno valid, ERROR:failure.
@@ -232,7 +233,11 @@ static int tftp_rcvack(int sd, FAR uint8_t *packet,
/* Success! */
ninfo("Received ACK for block %d\n", rblockno);
- *blockno = rblockno;
+ if (blockno != NULL)
+ {
+ *blockno = rblockno;
+ }
+
return OK;
}
}