<p>Patch set 6:<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/9174">View Change</a></p><p>9 comments:</p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0;"><p><a href="https://gerrit.asterisk.org/#/c/9174/6/pbx/pbx_dundi.c">File pbx/pbx_dundi.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/9174/6/pbx/pbx_dundi.c@a4849">Patch Set #6, Line 4849:</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><br><br></pre></blockquote></p><p style="white-space: pre-wrap; word-wrap: break-word;">Why was this check removed?</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/9174/6/pbx/pbx_dundi.c@2727">Patch Set #6, Line 2727:</a> <code style="font-family:monospace,monospace">                 &peer->eid), ast_sockaddr_stringify_host(&peer->addr),</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">This is a change to the command behavior.  If peer->addr is not set or uninitialized then we output "(null)" now instead of "(Unspecified)".</p><p style="white-space: pre-wrap; word-wrap: break-word;">If we were to include or exclude peers with an unspecified address we won't get what we would get before.</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/9174/6/pbx/pbx_dundi.c@2744">Patch Set #6, Line 2744:</a> <code style="font-family:monospace,monospace">                                  ast_sockaddr_stringify_host(&peer->addr),</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">This is a change to the command behavior.  If peer->addr is not set or uninitialized then we output "(null)" now instead of "(Unspecified)".</p><p style="white-space: pre-wrap; word-wrap: break-word;">If we were to include or exclude peers with an unspecified address we won't get what we would get before.</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/9174/6/pbx/pbx_dundi.c@4827">Patch Set #6, Line 4827:</a> <code style="font-family:monospace,monospace">      strcpy(ip, ast_sockaddr_stringify_fmt(&addrs[0], AST_SOCKADDR_STR_ADDR));</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">Using strcpy() is unsafe as it can overwrite the buffer if the copied string is too big.  You should pass in the size of the ip buffer and use ast_copy_string().</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/9174/6/pbx/pbx_dundi.c@4954">Patch Set #6, Line 4954:</a> <code style="font-family:monospace,monospace">   if (ast_sockaddr_isnull(sin)) { </code></p><p style="white-space: pre-wrap; word-wrap: break-word;">red blob</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/9174/6/pbx/pbx_dundi.c@4955">Patch Set #6, Line 4955:</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;">            ((struct sockaddr_in *)&sin->ss)->sin_addr.s_addr = INADDR_ANY;<br>             sin->ss.ss_family = AF_INET;<br>               sin->len = sizeof(struct sockaddr_in);<br></pre></blockquote></p><p style="white-space: pre-wrap; word-wrap: break-word;">Directly setting values in sin seems just wrong.</p><p style="white-space: pre-wrap; word-wrap: break-word;">How about just calling the function below instead?</p><p style="white-space: pre-wrap; word-wrap: break-word;">ast_sockaddr_parse(sin, "0.0.0.0", 0);</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/9174/6/pbx/pbx_dundi.c@4958">Patch Set #6, Line 4958:</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;">               /* handling no bind address but port in config  */<br>            if (last_port ==0) {<br>                  ast_sockaddr_set_port(sin, DUNDI_PORT);<br>                       last_port = ast_sockaddr_port(sin);<br>           } else {<br>                      ast_sockaddr_set_port(sin, last_port);<br>                }<br></pre></blockquote></p><p style="white-space: pre-wrap; word-wrap: break-word;">Pull this out of the if block and put it after.</p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">if (ast_sockaddr_isnull()) {<br>}<br>if (last_port == 0) {<br>   ast_sockaddr_set_port(sin, DUNDI_PORT);<br>   last_port = ast_sockaddr_port(sin);<br>} else {<br>   ast_sockaddr_set_port(sin, last_port);<br>}</pre></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/9174/6/pbx/pbx_dundi.c@4967">Patch Set #6, Line 4967:</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;">    if (!ast_sockaddr_port(sin)) {<br>                ast_sockaddr_set_port(sin, DUNDI_PORT);<br>               last_port = ast_sockaddr_port(sin);<br>   }<br></pre></blockquote></p><p style="white-space: pre-wrap; word-wrap: break-word;">This isn't right.  With the change above it isn't needed either.</p></li><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.asterisk.org/#/c/9174/6/pbx/pbx_dundi.c@5046">Patch Set #6, Line 5046:</a> <code style="font-family:monospace,monospace">    if (set_config("dundi.conf", &sin, 1))</code></p><p style="white-space: pre-wrap; word-wrap: break-word;">You need to initialize sin with ast_sockaddr_setnull().</p></li></ul></li></ul><p>To view, visit <a href="https://gerrit.asterisk.org/9174">change 9174</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/9174"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 15 </div>
<div style="display:none"> Gerrit-MessageType: comment </div>
<div style="display:none"> Gerrit-Change-Id: Ia9e8dc3d153de7a291dbda4bd87fc827dd2bb846 </div>
<div style="display:none"> Gerrit-Change-Number: 9174 </div>
<div style="display:none"> Gerrit-PatchSet: 6 </div>
<div style="display:none"> Gerrit-Owner: Kirsty Tyerman <kirsty.tyerman@boeing.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kirsty Tyerman <kirsty.tyerman@boeing.com> </div>
<div style="display:none"> Gerrit-Reviewer: Matthew Fredrickson <creslin@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Richard Mudgett <rmudgett@digium.com> </div>
<div style="display:none"> Gerrit-Comment-Date: Wed, 11 Jul 2018 21:35:46 +0000 </div>
<div style="display:none"> Gerrit-HasComments: Yes </div>
<div style="display:none"> Gerrit-HasLabels: Yes </div>