<p>Kevin Harwell <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/18104">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Joshua Colp: Looks good to me, but someone else must approve
Benjamin Keith Ford: Looks good to me, approved
Kevin Harwell: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">logger: workaround woefully small BUFSIZ in MUSL<br><br>MUSL defines BUFSIZ as 1024 which is not reasonable for log messages.<br><br>More broadly, BUFSIZ is the amount of buffering stdio.h does, which<br>is arbitrary and largely orthogonal to what logging should accept<br>as the maximum message size.<br><br>ASTERISK-29928<br><br>Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com><br>Change-Id: Iaa49fbbab029c64ae3d95e4b18270e0442cce170<br>---<br>M main/logger.c<br>1 file changed, 10 insertions(+), 5 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/main/logger.c b/main/logger.c</span><br><span>index e9f8f96..d742b49 100644</span><br><span>--- a/main/logger.c</span><br><span>+++ b/main/logger.c</span><br><span>@@ -97,6 +97,11 @@</span><br><span> static int logger_messages_discarded;</span><br><span> static unsigned int high_water_alert;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/* On some platforms, like those with MUSL as the runtime, BUFSIZ is</span><br><span style="color: hsl(120, 100%, 40%);">+ * unreasonably small (1024). Use a larger value in those environments.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+#define LOGMSG_SIZE MAX(BUFSIZ, 8192)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> static enum rotatestrategy {</span><br><span> NONE = 0, /* Do not rotate log files at all, instead rely on external mechanisms */</span><br><span> SEQUENTIAL = 1 << 0, /* Original method - create a new file, in order */</span><br><span>@@ -1665,7 +1670,7 @@</span><br><span> static void logger_print_normal(struct logmsg *logmsg)</span><br><span> {</span><br><span> struct logchannel *chan = NULL;</span><br><span style="color: hsl(0, 100%, 40%);">- char buf[BUFSIZ];</span><br><span style="color: hsl(120, 100%, 40%);">+ char buf[LOGMSG_SIZE];</span><br><span> int level = 0;</span><br><span> </span><br><span> AST_RWLIST_RDLOCK(&logchannels);</span><br><span>@@ -1698,13 +1703,13 @@</span><br><span> </span><br><span> /* Don't use LOG_MAKEPRI because it's broken in glibc<2.17 */</span><br><span> syslog_level = chan->facility | syslog_level; /* LOG_MAKEPRI(chan->facility, syslog_level); */</span><br><span style="color: hsl(0, 100%, 40%);">- if (!chan->formatter.format_log(chan, logmsg, buf, BUFSIZ)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!chan->formatter.format_log(chan, logmsg, buf, sizeof(buf))) {</span><br><span> syslog(syslog_level, "%s", buf);</span><br><span> }</span><br><span> }</span><br><span> break;</span><br><span> case LOGTYPE_CONSOLE:</span><br><span style="color: hsl(0, 100%, 40%);">- if (!chan->formatter.format_log(chan, logmsg, buf, BUFSIZ)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!chan->formatter.format_log(chan, logmsg, buf, sizeof(buf))) {</span><br><span> ast_console_puts_mutable_full(buf, logmsg->level, logmsg->sublevel);</span><br><span> }</span><br><span> break;</span><br><span>@@ -1716,7 +1721,7 @@</span><br><span> continue;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (chan->formatter.format_log(chan, logmsg, buf, BUFSIZ)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (chan->formatter.format_log(chan, logmsg, buf, sizeof(buf))) {</span><br><span> continue;</span><br><span> }</span><br><span> </span><br><span>@@ -1780,7 +1785,7 @@</span><br><span> }</span><br><span> </span><br><span> /* Build string */</span><br><span style="color: hsl(0, 100%, 40%);">- res = ast_str_set_va(&buf, BUFSIZ, fmt, ap);</span><br><span style="color: hsl(120, 100%, 40%);">+ res = ast_str_set_va(&buf, LOGMSG_SIZE, fmt, ap);</span><br><span> </span><br><span> /* If the build failed, then abort and free this structure */</span><br><span> if (res == AST_DYNSTR_BUILD_FAILED) {</span><br><span></span><br></pre><div style="white-space:pre-wrap"></div><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/18104">change 18104</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/+/18104"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 18 </div>
<div style="display:none"> Gerrit-Change-Id: Iaa49fbbab029c64ae3d95e4b18270e0442cce170 </div>
<div style="display:none"> Gerrit-Change-Number: 18104 </div>
<div style="display:none"> Gerrit-PatchSet: 4 </div>
<div style="display:none"> Gerrit-Owner: Philip Prindeville <philipp@redfish-solutions.com> </div>
<div style="display:none"> Gerrit-Reviewer: Benjamin Keith Ford <bford@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>