<p style="white-space: pre-wrap; word-wrap: break-word;"><br>> 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><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Sorry, I am kind of afraid to change the core function behavior for a simple problem fix. Moreover the semantics of the websocket code is not about string copy anyway, it is more about memory buffer.<br> <br>> Changing the function to the below should do it.<br>> <br>> 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>> }</pre><p style="white-space: pre-wrap; word-wrap: break-word;">It might be potentially harmful as well. Here it doesn't set \0 byte if size is 0 while it probably should. Speed needs test too.<br></p><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: Sun, 05 Jul 2020 08:09:09 +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>