<p>Patch set 3:<span style="border-radius: 3px; display: inline-block; margin: 0 2px; padding: 4px;background-color: #ffd4d4;">Code-Review -1</span></p><p><a href="https://gerrit.asterisk.org/10869">View Change</a></p><p>4 comments:</p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0;"><p><a href="https://gerrit.asterisk.org/#/c/10869/3/main/http.c">File main/http.c:</a></p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/10869/3/main/http.c@85">Patch Set #3, Line 85:</a> <code style="font-family:monospace,monospace">#define MAX_CONTENT_LENGTH 40960</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">ast_http_create_response uses MAX_CONTENT_LENGTH for the default buffer size of the response. I suspect the vast majority of responses are much smaller than 40k, I don't think it's appropriate to allocate so much memory in this function (this is the reason for me giving -1).</p><p style="white-space: pre-wrap; word-wrap: break-word;">This expands the maximum bytes accepted by ast_http_get_contents which is run before checking authentication on HTTP requests. I'm inclined to think that 40k isn't a risk of over-running memory but I'm mentioning it to be sure others give this a thought.</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/10869/3/main/http.c@922">Patch Set #3, Line 922:</a> <code style="font-family:monospace,monospace"> total = 0;</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">Nit: Please initialize in the declaration, `int total = 0;` above.</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/10869/3/main/http.c@923">Patch Set #3, Line 923:</a> <code style="font-family:monospace,monospace"> while(1) {</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">Nit: while is not a function, we put a space after it `while (1) {`.</p><p style="white-space: pre-wrap; word-wrap: break-word;">I think we could also use `while (total != length)`, then get rid of the `if (total >= length) { break; }` below. Once the call to ast_iostream_read is fixed to prevent buffer overrun `total > length` will be impossible.</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/10869/3/main/http.c@924">Patch Set #3, Line 924:</a> <code style="font-family:monospace,monospace"> res = ast_iostream_read(ser->stream, buf + total, length);</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">I think this allows buffer overrun after the first iteration (when total != 0).</p></li></ul></li></ul><p>To view, visit <a href="https://gerrit.asterisk.org/10869">change 10869</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/10869"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: comment </div>
<div style="display:none"> Gerrit-Change-Id: I48a401aa64a21c3b37bf3cb4e0486d64b7dd8aa1 </div>
<div style="display:none"> Gerrit-Change-Number: 10869 </div>
<div style="display:none"> Gerrit-PatchSet: 3 </div>
<div style="display:none"> Gerrit-Owner: sungtae kim <pchero21@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Corey Farrell <git@cfware.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation (1000185) </div>
<div style="display:none"> Gerrit-Reviewer: Michael L. Young <elgueromexicano@gmail.com> </div>
<div style="display:none"> Gerrit-Comment-Date: Wed, 09 Jan 2019 16:48:40 +0000 </div>
<div style="display:none"> Gerrit-HasComments: Yes </div>
<div style="display:none"> Gerrit-HasLabels: Yes </div>