<p>Patch set 1:<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/9510">View Change</a></p><p>7 comments:</p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0;"><p><a href="https://gerrit.asterisk.org/#/c/9510/1//COMMIT_MSG">Commit Message:</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/9510/1//COMMIT_MSG@7">Patch Set #1, Line 7:</a> <code style="font-family:monospace,monospace">avoid merging command and regular T140 text</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">Please use the commit message format as described on the linked wiki page:</p><p style="white-space: pre-wrap; word-wrap: break-word;">https://wiki.asterisk.org/wiki/display/AST/Commit+Messages</p></li></ul></li><li style="margin: 0; padding: 0;"><p><a href="https://gerrit.asterisk.org/#/c/9510/1/res/res_rtp_asterisk.c">File res/res_rtp_asterisk.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/9510/1/res/res_rtp_asterisk.c@6105">Patch Set #1, Line 6105:</a> <code style="font-family:monospace,monospace"> if ( !rtp->red ) return 0;</code></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Guidelines:<br>if (test) {<br>   return 0;<br>}</pre><p style="white-space: pre-wrap; word-wrap: break-word;">Note spacing around parentheses and use of curly braces.</p><p style="white-space: pre-wrap; word-wrap: break-word;">https://wiki.asterisk.org/wiki/display/AST/Coding+Guidelines</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/9510/1/res/res_rtp_asterisk.c@6108">Patch Set #1, Line 6108:</a> <code style="font-family:monospace,monospace">           const unsigned char * primary = red->buf_data;</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">Spacing:</p><p style="white-space: pre-wrap; word-wrap: break-word;">const unsigned char *primary = red->buf_data;</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/9510/1/res/res_rtp_asterisk.c@6110">Patch Set #1, Line 6110:</a> <code style="font-family:monospace,monospace">                  (primary[0] == 0x08 || primary[0] == 0x0a || primary[0] == 0x0d)) {</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">Guidelines: Use tabs to indent not spaces.</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/9510/1/res/res_rtp_asterisk.c@6113">Patch Set #1, Line 6113:</a> </p><p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><pre style="font-family: monospace,monospace; white-space: pre-wrap;">            }<br>             else {<br></pre></blockquote></p><p style="white-space: pre-wrap; word-wrap: break-word;">Guidelines:<br>if () {<br>} else {<br>}</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/9510/1/res/res_rtp_asterisk.c@6116">Patch Set #1, Line 6116:</a> <code style="font-family:monospace,monospace">                       if (primary[0] == 0x08 || primary[0] == 0x0a || primary[0] == 0x0d) {</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">We can read beyond the frame->data.ptr buffer if frame->datalen == 0.  We have only checked if frame->datalen > -1 at this point.</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/9510/1/res/res_rtp_asterisk.c@6108">Patch Set #1, Line 6108:</a> </p><p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><pre style="font-family: monospace,monospace; white-space: pre-wrap;">           const unsigned char * primary = red->buf_data;<br>             if (red->t140.datalen > 0 &&<br>                (primary[0] == 0x08 || primary[0] == 0x0a || primary[0] == 0x0d)) {<br>                       /* flush previous t140 packet if it is a command */<br>                   ast_rtp_write(instance, &rtp->red->t140);<br>           }<br>             else {<br>                        primary = frame->data.ptr;<br>                 if (primary[0] == 0x08 || primary[0] == 0x0a || primary[0] == 0x0d) {<br>                         /* flush previous t140 packet we send commands */<br>                             ast_rtp_write(instance, &rtp->red->t140);<br>                   }<br>             }<br></pre></blockquote></p><p style="white-space: pre-wrap; word-wrap: break-word;">I think the code should be this way:</p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">if (red->t140.datalen > 0) {<br>   const unsigned char *primary = red->buf_data;</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">   /* There is something already in the T.140 buffer */<br>   if (primary[0] == 0x08 ....) {<br>       /* Flush the previous T.140 packet if it is a command */<br>       ast_rtp_write(instance, &rtp->red->t140);<br>   } else {<br>       primary = frame->data->ptr;<br>       if (primary[0] == 0x08 ....) {<br>          /* Flush the previous T.140 packet if we are buffering a command now */<br>          ast_rtp_write(instance, &rtp->red->t140);<br>       }<br>   }<br>}</pre></li></ul></li></ul><p>To view, visit <a href="https://gerrit.asterisk.org/9510">change 9510</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/9510"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-MessageType: comment </div>
<div style="display:none"> Gerrit-Change-Id: Ifbe993311410fa855cb8aa4a12084db75f413462 </div>
<div style="display:none"> Gerrit-Change-Number: 9510 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Emmanuel BUU <emmanuel.buu@ives.fr> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Richard Mudgett <rmudgett@digium.com> </div>
<div style="display:none"> Gerrit-Comment-Date: Wed, 18 Jul 2018 16:20:59 +0000 </div>
<div style="display:none"> Gerrit-HasComments: Yes </div>
<div style="display:none"> Gerrit-HasLabels: Yes </div>