summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndrew Goodbody <[email protected]>2026-01-14 15:12:09 +0000
committerJerome Forissier <[email protected]>2026-02-04 09:04:36 +0100
commit8df6b78746ee1f4f0bb750aec9c4da2fb31d3e33 (patch)
tree6726cfacc560cd604a1bec0c3245ebb345ca66bc /lib
parentf2566c3a71a541a5bdd34b78a9d33934f6925154 (diff)
net: lwip: tftp: Do not write past buffer end
sprintf will add a trailing \0 so manually adding a trailing \0 will result in an extra unaccounted for character being written. This overwrote the first byte of the following allocation block resulting in unexpected behavior. This was found by Running 'pxe get' with no available file resulting in multiple attempts, using the default algorithm, to attempt to find a file. Eventually there would be a failed assert when free() was called. Failing the assert would result in a system reset. Fixes: 27d7ccda94fa ("net: lwip: tftp: add support of blksize option to client") Reported-by: Michal Simek <[email protected]> Tested-by: Michal Simek <[email protected]> Signed-off-by: Andrew Goodbody <[email protected]> Tested-by: Tom Rini <[email protected]> # Pine64+ Reviewed-by: Jerome Forissier <[email protected]> Reviewed-by: Jerome Forissier <[email protected]>
Diffstat (limited to 'lib')
-rw-r--r--lib/lwip/lwip/src/apps/tftp/tftp.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/lwip/lwip/src/apps/tftp/tftp.c b/lib/lwip/lwip/src/apps/tftp/tftp.c
index ecb6c55ae11..25da952e925 100644
--- a/lib/lwip/lwip/src/apps/tftp/tftp.c
+++ b/lib/lwip/lwip/src/apps/tftp/tftp.c
@@ -191,7 +191,7 @@ send_request(const ip_addr_t *addr, u16_t port, u16_t opcode, const char* fname,
MEMCPY(payload+2, fname, fname_length);
MEMCPY(payload+2+fname_length, mode, mode_length);
if (tftp_state.blksize)
- sprintf(payload+2+fname_length+mode_length, "blksize%c%d%c", 0, tftp_state.blksize, 0);
+ sprintf(payload+2+fname_length+mode_length, "blksize%c%d", 0, tftp_state.blksize);
tftp_state.wait_oack = true;
ret = udp_sendto(tftp_state.upcb, p, addr, port);