Skip to content
This repository has been archived by the owner on Sep 10, 2024. It is now read-only.

OTA.py example: issues when python file contains "\r\n\r\n" #158

Open
SebastiaanMerckx opened this issue Oct 29, 2021 · 1 comment
Open

Comments

@SebastiaanMerckx
Copy link

Issue:

I observed while testing OTA upgrade (using lib OTA.py), that the hash for a specific file was always incorrectly calculated by the OTA.py.

In fact, the issue is that the stripping of HTML header in "get_data()" function does not properly work if the "result" contains more than 1 "\r\n\r\n".
result = result.decode().split("\r\n\r\n")[1].encode()

To be replaced with something like:

index = result.decode().find("\r\n\r\n")
result = result[index+4:]

This issue can be reproduced by running the OTA server and making sure that a file containing "\r\n\r\n" (2 empty lines on top, or 1 empty line between 2 statements) needs to be downloaded and hash-verified.

@SebastiaanMerckx
Copy link
Author

or in 1 line:
result = result[result.decode().find("\r\n\r\n")+4:]

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant