<p>Jaco Kroon has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/16640">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">term: truncate the message rather than the escapes.<br><br>This is a two edged sword.  Without this we end up potentially odd<br>escape sequences (which has been seen to cause screen corruption through<br>long function names in ast_debug), with this we change the meaning of<br>the message (but truncation could happen in any case).<br><br>Change-Id: I80ef7a4bfd2947e090ef830143391d11baebdb0d<br>Signed-off-by: Jaco Kroon <jaco@uls.co.za><br>---<br>M main/term.c<br>1 file changed, 12 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/40/16640/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/main/term.c b/main/term.c</span><br><span>index be10163..cbe3c40 100644</span><br><span>--- a/main/term.c</span><br><span>+++ b/main/term.c</span><br><span>@@ -235,6 +235,8 @@</span><br><span> char *term_color(char *outbuf, const char *inbuf, int fgcolor, int bgcolor, int maxout)</span><br><span> {</span><br><span>    int attr = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ char *tail_out;</span><br><span style="color: hsl(120, 100%, 40%);">+       int p, tl;</span><br><span> </span><br><span>       if (!vt100compat) {</span><br><span>          ast_copy_string(outbuf, inbuf, maxout);</span><br><span>@@ -262,10 +264,18 @@</span><br><span>              if (!bgcolor) {</span><br><span>                      bgcolor = COLOR_BLACK;</span><br><span>               }</span><br><span style="color: hsl(0, 100%, 40%);">-               snprintf(outbuf, maxout, "%c[%d;%d;%dm%s%s", ESC, attr, fgcolor, bgcolor + 10, inbuf, term_end());</span><br><span style="color: hsl(120, 100%, 40%);">+          p = snprintf(outbuf, maxout, "%c[%d;%d;%dm", ESC, attr, fgcolor, bgcolor + 10);</span><br><span>    } else {</span><br><span style="color: hsl(0, 100%, 40%);">-                snprintf(outbuf, maxout, "%c[%d;%dm%s%s", ESC, attr, fgcolor, inbuf, term_end());</span><br><span style="color: hsl(120, 100%, 40%);">+           p = snprintf(outbuf, maxout, "%c[%d;%dm", ESC, attr, fgcolor);</span><br><span>     }</span><br><span style="color: hsl(120, 100%, 40%);">+     tail_out = term_end();</span><br><span style="color: hsl(120, 100%, 40%);">+        tl = strlen(tail_out);</span><br><span style="color: hsl(120, 100%, 40%);">+        if (maxout <= p + tl) {</span><br><span style="color: hsl(120, 100%, 40%);">+            /* not even the ANSI sequences will fit in the buffer */</span><br><span style="color: hsl(120, 100%, 40%);">+              ast_copy_string(outbuf, inbuf, maxout);</span><br><span style="color: hsl(120, 100%, 40%);">+               return outbuf;</span><br><span style="color: hsl(120, 100%, 40%);">+        }</span><br><span style="color: hsl(120, 100%, 40%);">+     snprintf(outbuf + p, maxout - p, "%.*s%s", maxout - p - tl, inbuf, tail_out);</span><br><span>      return outbuf;</span><br><span> }</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/16640">change 16640</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/+/16640"/><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: I80ef7a4bfd2947e090ef830143391d11baebdb0d </div>
<div style="display:none"> Gerrit-Change-Number: 16640 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Jaco Kroon <jaco@uls.co.za> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>