-
Notifications
You must be signed in to change notification settings - Fork 11
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 client buffer not read correctly #131
Conversation
Do you have test cases that trigger the issue? In my main https://github.com/CurlyMoo/webserver repository i use test cases to validate various parts of the webserver. Without it, i can't guarantee that each issue is properly adressed in future code changes. |
Yes, see Egyras#481. The concast testrule from that issue cause the post to timeout. The pr/121 code isn't necesarry as the bug is due to the length of the rule. The fact that the rule uses commands from pr/121 isn't important. After a few hours of debugging I found that it didn't find the ending boundary with CRLN with '--' in the mulitpart decoding as the client buffer was split exaclty at this point. My temporary fix to check on CRLN with only one dash '-' fixed it also but in this PR there is a better way. It just rolls back the client buf into the read buf if these chars are found on the end of the client buf. Then I tried enlarging the client buffer from 128 to higher and stumbled on more bugs. I believe these changes are fixing these issue but I am sure it isn't working for all corner situation yet. |
Can you explain how I can run this myself? |
My advice would be to fix the webserver code here https://github.com/CurlyMoo/webserver by providing additional unittests. I think the best approach would be not to sent me Wireshark output, but instead create a additional unittest yourself. You may use the |
https://github.com/CurlyMoo/webserver?tab=readme-ov-file#linux |
The code in that github repo isn't up to date on which heishamon has. For example the posEnd part (even without my changes) are missing in the parse_request function substep 4. owh it even fails without any changes to the repo |
Wierd stuff, i though i just checked if it worked before posting. |
I see, the travis connection broke so i didn't got feedback anymore on top of my own checks. |
At least i know what i can do next; fix the current webserver code. |
Ok let me know when it works again and then i'll test my changes. |
The strnstr function contains a bug also. If the str to find is at end of first string then it gets into overflow. This issue can explain some issue's I had seen before with not detecting the end boundary
|
You mean this case? strnstr((unsigned char *)"foo bar", "bar", strlen("foo bar")); |
Yes. |
I see that the webserver uses it's own https://github.com/CurlyMoo/webserver/blob/main/webserver.cpp#L745-L761 |
LOL,.. but that is char * result and all calls are unsigned char * so it matches to the one in strnstr.h |
Stupid C++ vs C |
I'm a bit further in testing the unittests and why it suddenly failed after some years. The tests as defined in this script all work fine: However, a test with just the defaults |
This is the commit that started to fail running the defaults: |
I reverted that specific commit because it was crap. The unittests work again. |
Just added a PR to your repo to fix a few issues and add the test 16 which caused it to fail before |
If you sync the webserver to here, i will do so in the rules PR after this PR is merged. |
Hmm I tried some local syncing and now notice that it seems to use 'root' as name :) |
I saw. That’s why I left out the ‘signed-off’ message.
|
3634481
to
b6f0af7
Compare
I think this should be it. I believe the revert of that commit you did should have been merged also but not sure so if you can do a quick visual check of the diff that would be great. |
Why don't you just overwrite |
That was too easy and I thought I wasn't using git properly then :-) For the ESP32 code I need to apply the diff also so I think this is the best way now. |
There are some lines though that I don’t recognize.
|
Please let me know which ones |
The ones that cannot be found in my own webserver repo. |
As I said, those are the necessary changes for heishamon to work with serial logging |
I don't see them anymore, so i think it's fine. |
Some changes to how the read buffer is read (parsed) using the client buffer. These changes are necessary for some cases (like boundaries split on the end of the client buffer). Also, changing the client buffer from 128 (default) to higher (for example 512) now works with this changes.