<p>Joshua Colp <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/14475">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Joshua Colp: Looks good to me, but someone else must approve; Approved for Submit
George Joseph: Looks good to me, approved
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip_logger.c: correct the return value checks when writing to pcap<br>files<br><br>fwrite() does return the number of elements written and not the<br>number of bytes. However asterisk is currently comparing the return<br>value to the size of the written element what means that asterisk logs<br>five WARNING messages on every packet written to the pcap file.<br><br>This patch changes the code to check for the correct value, which will<br>always be 1.<br><br>ASTERISK-28921 #close<br><br>Change-Id: I2455032d9cb4c5a500692923f9e2a22e68b08fc2<br>---<br>M res/res_pjsip_logger.c<br>1 file changed, 5 insertions(+), 5 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/res/res_pjsip_logger.c b/res/res_pjsip_logger.c</span><br><span>index cc79f61..8380bd6 100644</span><br><span>--- a/res/res_pjsip_logger.c</span><br><span>+++ b/res/res_pjsip_logger.c</span><br><span>@@ -246,19 +246,19 @@</span><br><span> /* We lock the logger session since we're writing these out in parts */</span><br><span> ao2_wrlock(session);</span><br><span> if (session->pcap_file) {</span><br><span style="color: hsl(0, 100%, 40%);">- if (fwrite(&pcap_record_header, sizeof(struct pcap_record_header), 1, session->pcap_file) != sizeof(struct pcap_record_header)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (fwrite(&pcap_record_header, sizeof(struct pcap_record_header), 1, session->pcap_file) != 1) {</span><br><span> ast_log(LOG_WARNING, "Writing PCAP header failed: %s\n", strerror(errno));</span><br><span> }</span><br><span style="color: hsl(0, 100%, 40%);">- if (fwrite(&pcap_ethernet_header, sizeof(struct pcap_ethernet_header), 1, session->pcap_file) != sizeof(struct pcap_ethernet_header)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (fwrite(&pcap_ethernet_header, sizeof(struct pcap_ethernet_header), 1, session->pcap_file) != 1) {</span><br><span> ast_log(LOG_WARNING, "Writing ethernet header to pcap failed: %s\n", strerror(errno));</span><br><span> }</span><br><span style="color: hsl(0, 100%, 40%);">- if (fwrite(pcap_ip_header, pcap_ip_header_len, 1, session->pcap_file) != pcap_ip_header_len) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (fwrite(pcap_ip_header, pcap_ip_header_len, 1, session->pcap_file) != 1) {</span><br><span> ast_log(LOG_WARNING, "Writing IP header to pcap failed: %s\n", strerror(errno));</span><br><span> }</span><br><span style="color: hsl(0, 100%, 40%);">- if (fwrite(&pcap_udp_header, sizeof(struct pcap_udp_header), 1, session->pcap_file) != sizeof(struct pcap_udp_header)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (fwrite(&pcap_udp_header, sizeof(struct pcap_udp_header), 1, session->pcap_file) != 1) {</span><br><span> ast_log(LOG_WARNING, "Writing UDP header to pcap failed: %s\n", strerror(errno));</span><br><span> }</span><br><span style="color: hsl(0, 100%, 40%);">- if (fwrite(msg, msg_len, 1, session->pcap_file) != msg_len) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (fwrite(msg, msg_len, 1, session->pcap_file) != 1) {</span><br><span> ast_log(LOG_WARNING, "Writing UDP payload to pcap failed: %s\n", strerror(errno));</span><br><span> }</span><br><span> }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/14475">change 14475</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/+/14475"/><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: I2455032d9cb4c5a500692923f9e2a22e68b08fc2 </div>
<div style="display:none"> Gerrit-Change-Number: 14475 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: nappsoft <infos@nappsoft.ch> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>