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

https://github.com/esp8266/Arduino/pull/7543 corrupt binary upload like index.html.gz #7723

Closed
1 task
luc-github opened this issue Nov 25, 2020 · 1 comment · Fixed by #7728
Closed
1 task
Assignees

Comments

@luc-github
Copy link
Contributor

luc-github commented Nov 25, 2020

Basic Infos

  • [ X] This issue complies with the issue POLICY doc.
  • [ X] I have read the documentation at readthedocs and the issue is not addressed there.
  • [X ] I have tested that the issue is present in current master branch (aka latest git).
  • [X ] I have searched the issue tracker for a similar issue.
  • If there is a stack dump, I have decoded it. N/A
  • [ X] I have filled out all fields below.

Platform

  • Hardware: [ESP-12]
  • Core Version: [latest git 25/11/2020]
  • Development Env: [Arduino IDE]
  • Operating System: [Windows]

Settings in IDE

  • Module: [Nodemcu]
  • Flash Mode: [dio]
  • Flash Size: [4MB/FS2MB]
  • lwip Variant: [v2 Lower Memory]
  • Reset Method: [nodemcu]
  • Flash Frequency: [40Mhz]
  • CPU Frequency: [160MHz]
  • Upload Using: [SERIAL]
  • Upload Speed: [115200r] (serial upload only)

Problem Description

Since this commit #7543, binary upload like index.html.gz is corrupted
so the result is when web access to corrupted file the encodding is not recognized

Need to upload file - then try to access it using webserver
with commit the page cannot be displayed
without commit everything is fine

No issue with text file as there is not need for browser to expand the file, even corrupted it is loaded
good file index.html(2).gz
corrupted file index.html(1).gz

image

For what I can see the 0D 0A code is modified in uploaded file - corrupting it

MCVE Sketch

I used FSBrowser sample to check

@earlephilhower
Copy link
Collaborator

Thanks for the clear repro steps. I was able to duplicate locally. Basically, once a 0x0d comes in the following byte is garbled on writing to flash, so the change listed has an issue. I'll look into it.

@earlephilhower earlephilhower self-assigned this Nov 28, 2020
earlephilhower added a commit to earlephilhower/Arduino that referenced this issue Nov 28, 2020
Use a simpler, cleaner implementation of multipart form detection as
defined in https://tools.ietf.org/html/rfc7578 .

Implements a simple state machine that detects the \r\n--<boundary>
stream in input a character at a time, instead of buffering and
comparing in chunks which can miss things due to alignment issues and
which also had a problem with replacing characters in a binary stream.

Fixes esp8266#7723
earlephilhower added a commit that referenced this issue Nov 29, 2020
Use a simpler, cleaner implementation of multipart form detection as
defined in https://tools.ietf.org/html/rfc7578 .

Implements a simple state machine that detects the `\r\n--<boundary>`
stream in input a character at a time, instead of buffering and
comparing in chunks which can miss things due to alignment issues and
which also had a problem with replacing characters in a binary stream.

Adjust the private _uploadReadByte function to return -1 on error (like
a read()), and the main file upload handler to use that return value
instead of duplicating logic.

Fixes #7723
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 a pull request may close this issue.

2 participants