Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protect against a empty or tiny / invalid file #401

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions main/http_server/http_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,12 @@ esp_err_t POST_WWW_update(httpd_req_t * req)
return ESP_OK;
}

// Don't attempt to write anything way too small to the partition
if (remaining < 32768) {
httpd_resp_send_err(req, HTTPD_400_BAD_REQUEST, "File provided is too small, likely corrupt or invalid");
return ESP_OK;
}

// Erase the entire www partition before writing
ESP_ERROR_CHECK(esp_partition_erase_range(www_partition, 0, www_partition->size));

Expand Down
Loading