Avoid ABEND when receiving request content and chunks#603
Avoid ABEND when receiving request content and chunks#603ChongZhou-Broadcom wants to merge 6 commits into
Conversation
|
I prefer that this becomes SLHAlloc2, by our current standard, adding an argument and having the original API function call a new one that has the new argument determine if the call should abort vs. return NULL. Default is abort. Also, is this code being called in a recovery.c recovery context. That would handle the abort already with no DDOS. AND when we have bugs that assert potential memory problems or DDOS, please make new files or subdirs under zowe-common-c/tests to repro and allow future regression testing. |
|
@JoeNemo Thank you for your review! My response is as below.
Totally agreed. Will change it soon.
Please correct me if I'm wrong. The only
Will do. |
| return (char *)data; | ||
| } | ||
|
|
||
| char *SLHAlloc_NoAbend(ShortLivedHeap *slh, int size) { |
There was a problem hiding this comment.
I think we should just factor out the logic out of SLHAlloc into something like SLHAllocInternal and then modify the behaviour in the wrapper functions (SLHAlloc and e.g., SLHAlloc2).
This kind of leaks abstraction.
There was a problem hiding this comment.
Yes, I agree. @JoeNemo suggested something similar. I have updated the implementation.
|
@JoeNemo I implemented the "SLHAlloc2" according to your suggestion. I created "SLHAlloc_NoAbend" because I was thinking about c++'s "new(std::nothrow)" :)
|
|
@JoeNemo Hi Joe, as you requested earlier, I added two test cases in tests/. Please review it when you have a moment. Thanks. |
877eab8 to
7893948
Compare
3453595 to
7465f87
Compare
7465f87 to
56b9d40
Compare
Signed-off-by: ch.zhou <chong.zhou@broadcom.com>
Signed-off-by: ch.zhou <chong.zhou@broadcom.com>
…untime by a test framework Signed-off-by: ch.zhou <chong.zhou@broadcom.com>
56b9d40 to
7f3034d
Compare
Signed-off-by: ch.zhou <chong.zhou@broadcom.com>
Signed-off-by: Zhou <chong.zhou@broadcom.com>
|


Proposed changes
When
processHttpFragmentis receiving the request content, either the first block or the subsequent chunks, it callsSLHAllocto allocate buffer. However,SLHAllocwill trigger ABEND when the preallocated short-lived buffer runs out of space. For example:zowe-common-c/c/httpserver.c
Lines 2390 to 2395 in 9803cfc
zowe-common-c/c/utils.c
Lines 1495 to 1513 in 9803cfc
It makes DDoS possible. This PR changes the behavior to return http/500 instead of ABEND when it fails to allocate buffer for request content.
However, I did not implement a configurable limit for the max content size, I only avoided ABEND. I was hesitating because it sounds like a good idea but the HTTP spec does not force such limit.
This PR addresses Issue: N/A
This PR depends upon the following PRs: N/A
Type of change
Please delete options that are not relevant.
PR Checklist
Please delete options that are not relevant.
Testing
N/A
Further comments
N/A