From 65e913ecd6be55da903b7862d705b7e89cb3c51d Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 30 Nov 2022 14:22:46 -0800 Subject: [PATCH] Fix writing files from web workflow Pico W changes assumed that f_write could handle a NULL fourth argument. It can't. --- supervisor/shared/web_workflow/web_workflow.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/supervisor/shared/web_workflow/web_workflow.c b/supervisor/shared/web_workflow/web_workflow.c index 3527090f1e..231b1e8ffb 100644 --- a/supervisor/shared/web_workflow/web_workflow.c +++ b/supervisor/shared/web_workflow/web_workflow.c @@ -907,8 +907,13 @@ static void _write_file_and_reply(socketpool_socket_obj_t *socket, _request *req error = true; break; } - f_write(&active_file, bytes, len, NULL); total_read += len; + UINT actual; + f_write(&active_file, bytes, len, &actual); + if (actual < (UINT)len) { + error = true; + break; + } } f_close(&active_file); @@ -917,7 +922,10 @@ static void _write_file_and_reply(socketpool_socket_obj_t *socket, _request *req #endif override_fattime(0); - if (new_file) { + if (error) { + _discard_incoming(socket, request->content_length - total_read); + _reply_server_error(socket, request); + } else if (new_file) { _reply_created(socket, request); } else { _reply_no_content(socket, request);