<blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><p style="white-space: pre-wrap; word-wrap: break-word;">Patch Set 1:</p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><p style="white-space: pre-wrap; word-wrap: break-word;">Patch Set 1: Code-Review-1</p><p style="white-space: pre-wrap; word-wrap: break-word;">(1 comment)</p><p style="white-space: pre-wrap; word-wrap: break-word;">Did you encounter an issue with the code?  Did ast_copy_string() read past the end of a buffer here?</p></blockquote><p style="white-space: pre-wrap; word-wrap: break-word;">Yes, I catched this with valgrind. ast_copy_string reads one byte after payload buffer which causes invalid read warning.</p></blockquote><p style="white-space: pre-wrap; word-wrap: break-word;">I think a better way to fix this would be to fix ast_copy_string() to not read past the end of the source buffer for this case.  This then has the potential to fix other places.  There are two places where the function is defined; in include/asterisk/strings.h and utils/extconf.c.</p><p style="white-space: pre-wrap; word-wrap: break-word;">Changing the function to the below should do it.</p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">void ast_copy_string(char *dst, const char *src, size_t size),<br>{<br> if (size) {<br>           while (--size && *src) {<br>                      *dst++ = *src++;<br>              }<br>             *dst = '\0';<br>  }<br>}<br></pre><p><a href="https://gerrit.asterisk.org/c/asterisk/+/14626">View Change</a></p><ul style="list-style: none; padding: 0;"></ul><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/14626">change 14626</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/c/asterisk/+/14626"/><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-Change-Id: Ib4a75cffeb1eb8cf01136ef30306bd623e531a2a </div>
<div style="display:none"> Gerrit-Change-Number: 14626 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Nickolay V. Shmyrev <nshmyrev@alphacephei.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: Richard Mudgett <rmudgett@digium.com> </div>
<div style="display:none"> Gerrit-Comment-Date: Fri, 03 Jul 2020 16:32:00 +0000 </div>
<div style="display:none"> Gerrit-HasComments: No </div>
<div style="display:none"> Gerrit-Has-Labels: No </div>
<div style="display:none"> Gerrit-MessageType: comment </div>