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

fix(esp_https_ota): only do ota when http status code is 200 (GIT8266O-842) #1265

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

movsb
Copy link

@movsb movsb commented Jan 5, 2024

A status code of 404 (Not Found) returned from the OTA server causes the esp8266 to continue to write to the partition until it encounters an error of "OTA image has invalid magic byte (expected 0xE9, saw 0xXX)". This is somewhat ridiculous. HTTP StatusCode should be the first thing that we should do to check its content is right or not, not the Magic after reading some body. If the status code isn't OK, we should just simply drop the body (not read anything).

As for the code of esp-idf, it should also be better that we first check if the code is HttpStatus_OK, then any others. Processing non-OK HTTP error codes is sometimes optional. They exist for providing more debugging information (except for Redirections. Or maybe not, some implementations give us on option automatically do the redirections for us, not everybody who uses it).

https://github.com/espressif/esp-idf/blob/master/components/esp_https_ota/src/esp_https_ota.c#L93-L135

@CLAassistant
Copy link

CLAassistant commented Jan 5, 2024

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot changed the title fix(esp_https_ota): only do ota when http status code is 200 fix(esp_https_ota): only do ota when http status code is 200 (GIT8266O-842) Jan 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants