-
-
Notifications
You must be signed in to change notification settings - Fork 383
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
"crow::multipart::message throws when the boundary is empty or malformed #931
Conversation
…med. added unit tests to check agains this behaviour
Quick question about this, I understand that raising an exception is a valid solution, but if this exception goes unhandled then we end up with a Would it be appropriate to just respond with a |
I have thought about automatically responding with an error code when this is detected but i mostly didn't know where to look to see how that can be achieved. If you point me in the right direction i'll try to make the necessary changes. One counter argument i can give to what you said is. If the user does not handle the error in his handler returning 500 seems completely fine to me since an internal error did happen but the user did not check for it so it is unknown (to me that seems completely reasonable). Any other unhandled error would have the same result i assume. But if you wish to automatically respond with this. The easiest way would probably be to have a BadRequestException that can be caught in the method that handles each handler. But let me know if there is a better way |
since the exception is the result of an error within the request itself, and since the only fix is to actually change the request, then it should be a
I agree, I think this would be ideal, Crow handles exceptions here. I think modifying the default exception handler to recognize a bad request exception is a valid solution. |
Yes i agree, i'll make the required changes as soon as i can |
…400 when a bad_request is thrown. adapted unittests
One question i have is. What if request itself could handle the multipart stuff, then when the request itself is being built the error would be caught way before it enters the user's handler. Wouldn't that be preferred ? |
well it's a design decision, as far as I can tell, the design is that
wouldn't putting this kind of logic in the handler be a good solution? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved, Thank you for your help!
This is related to issue #916 where the multipart message causes a segmentation fault when a multipart request with an empty boundary is received.
I added two throws to indicate whenever the boundary is empty or it could not be found/differs from the boundary inside the body.
I hope these changes are enough to prevent the code from being unable to parse the headers thus leaving to the segmentation faults.
I also added two new tests that aim to check that these exceptions are thrown whenever the boundary is either missing or not matching
Edit: Something that occured to me as an afterthought is that maybe the line that finds the "name" element should also be checked and emmit some exception or something to be 100% that this does not segfault in the future