[Asterisk-code-review] res_pjsip_logger.c: correct the return value checks when writing to p... (asterisk[16])
nappsoft
asteriskteam at digium.com
Fri May 29 04:35:28 CDT 2020
nappsoft has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/14449 )
Change subject: res_pjsip_logger.c: correct the return value checks when writing to pcap files
......................................................................
res_pjsip_logger.c: correct the return value checks when writing to pcap
files
fwrite() does not return the number of elements written and not the
number of bytes. However asterisk is currently comparing the return
value to the size of the written element what means that asterisk logs a
five WARNING messages on every packet written to the pcap file.
This patch changes the code to check for the correct value, which will
always be 1.
ASTERISK-28921 #close
Change-Id: I2455032d9cb4c5a500692923f9e2a22e68b08fc2
---
M res/res_pjsip_logger.c
1 file changed, 5 insertions(+), 5 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/49/14449/1
diff --git a/res/res_pjsip_logger.c b/res/res_pjsip_logger.c
index cc79f61..8380bd6 100644
--- a/res/res_pjsip_logger.c
+++ b/res/res_pjsip_logger.c
@@ -246,19 +246,19 @@
/* We lock the logger session since we're writing these out in parts */
ao2_wrlock(session);
if (session->pcap_file) {
- if (fwrite(&pcap_record_header, sizeof(struct pcap_record_header), 1, session->pcap_file) != sizeof(struct pcap_record_header)) {
+ if (fwrite(&pcap_record_header, sizeof(struct pcap_record_header), 1, session->pcap_file) != 1) {
ast_log(LOG_WARNING, "Writing PCAP header failed: %s\n", strerror(errno));
}
- if (fwrite(&pcap_ethernet_header, sizeof(struct pcap_ethernet_header), 1, session->pcap_file) != sizeof(struct pcap_ethernet_header)) {
+ if (fwrite(&pcap_ethernet_header, sizeof(struct pcap_ethernet_header), 1, session->pcap_file) != 1) {
ast_log(LOG_WARNING, "Writing ethernet header to pcap failed: %s\n", strerror(errno));
}
- if (fwrite(pcap_ip_header, pcap_ip_header_len, 1, session->pcap_file) != pcap_ip_header_len) {
+ if (fwrite(pcap_ip_header, pcap_ip_header_len, 1, session->pcap_file) != 1) {
ast_log(LOG_WARNING, "Writing IP header to pcap failed: %s\n", strerror(errno));
}
- if (fwrite(&pcap_udp_header, sizeof(struct pcap_udp_header), 1, session->pcap_file) != sizeof(struct pcap_udp_header)) {
+ if (fwrite(&pcap_udp_header, sizeof(struct pcap_udp_header), 1, session->pcap_file) != 1) {
ast_log(LOG_WARNING, "Writing UDP header to pcap failed: %s\n", strerror(errno));
}
- if (fwrite(msg, msg_len, 1, session->pcap_file) != msg_len) {
+ if (fwrite(msg, msg_len, 1, session->pcap_file) != 1) {
ast_log(LOG_WARNING, "Writing UDP payload to pcap failed: %s\n", strerror(errno));
}
}
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/14449
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I2455032d9cb4c5a500692923f9e2a22e68b08fc2
Gerrit-Change-Number: 14449
Gerrit-PatchSet: 1
Gerrit-Owner: nappsoft <infos at nappsoft.ch>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200529/5cb50053/attachment-0001.html>
More information about the asterisk-code-review
mailing list