altcp_abort() deallocates the connection PCB. A raw TCP receive callback
which calls it must return ERR_ABRT so the TCP input path does not access
the released PCB.

The wget receive callback instead returns ERR_BUF when storing received
data fails. Return ERR_ABRT after aborting the connection.

Fixes: e40c910e88a9 ("net-lwip: wget: add LMB and buffer checks")
Signed-off-by: James Hilliard <[email protected]>
---
 net/lwip/wget.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/lwip/wget.c b/net/lwip/wget.c
index 247ece18e2b..e8930da410b 100644
--- a/net/lwip/wget.c
+++ b/net/lwip/wget.c
@@ -206,7 +206,7 @@ static err_t httpc_recv_cb(void *arg, struct altcp_pcb 
*pcb, struct pbuf *pbuf,
        for (buf = pbuf; buf; buf = buf->next) {
                if (store_block(ctx, buf->payload, buf->len) < 0) {
                        altcp_abort(pcb);
-                       ret = ERR_BUF;
+                       ret = ERR_ABRT;
                        goto out;
                }
        }

-- 
2.53.0

Reply via email to