[Home]

Summary:ASTERISK-28921: Wrong return value check for fwrite when writing to pcap file
Reporter:nappsoft (nappsoft)Labels:patch
Date Opened:2020-05-29 00:38:16Date Closed:2020-06-01 08:48:32
Priority:MinorRegression?
Status:Closed/CompleteComponents:Resources/res_pjsip_logger
Versions:16.11.0 Frequency of
Occurrence
Constant
Related
Issues:
Environment:Attachments:( 0) correct_checks.diff
Description:When using the new feature that logs to pcap files one will get 5 lines with warnings for each packet written.

This is because of the fact that the wrong return value is being checked: fwrite does not return the number of bytes written, but the number of elements written. However asterisk is comparing the return value (which will always be 1) with the size of the element, resulting in the following output:

[May 29 07:22:23] WARNING[7274]: res_pjsip_logger.c:250 pjsip_logger_write_to_pcap: Writing PCAP header failed: Invalid argument
[May 29 07:22:23] WARNING[7274]: res_pjsip_logger.c:253 pjsip_logger_write_to_pcap: Writing ethernet header to pcap failed: Invalid argument
[May 29 07:22:23] WARNING[7274]: res_pjsip_logger.c:256 pjsip_logger_write_to_pcap: Writing IP header to pcap failed: Invalid argument
[May 29 07:22:23] WARNING[7274]: res_pjsip_logger.c:259 pjsip_logger_write_to_pcap: Writing UDP header to pcap failed: Invalid argument
[May 29 07:22:23] WARNING[7274]: res_pjsip_logger.c:262 pjsip_logger_write_to_pcap: Writing UDP payload to pcap failed: Invalid argument

The attached patch fixes this.
Comments:By: Asterisk Team (asteriskteam) 2020-05-29 00:38:17.628-0500

Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution.

A good first step is for you to review the [Asterisk Issue Guidelines|https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines] if you haven't already. The guidelines detail what is expected from an Asterisk issue report.

Then, if you are submitting a patch, please review the [Patch Contribution Process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process].

Please note that once your issue enters an open state it has been accepted. As Asterisk is an open source project there is no guarantee or timeframe on when your issue will be looked into. If you need expedient resolution you will need to find and pay a suitable developer. Asking for an update on your issue will not yield any progress on it and will not result in a response. All updates are posted to the issue when they occur.

By: Joshua C. Colp (jcolp) 2020-05-29 03:42:47.500-0500

Do you plan on putting this up for review?

By: nappsoft (nappsoft) 2020-05-29 04:37:30.244-0500

done

By: Friendly Automation (friendly-automation) 2020-06-01 08:48:33.314-0500

Change 14473 merged by Joshua Colp:
res_pjsip_logger.c: correct the return value checks when writing to pcap files

[https://gerrit.asterisk.org/c/asterisk/+/14473|https://gerrit.asterisk.org/c/asterisk/+/14473]

By: Friendly Automation (friendly-automation) 2020-06-01 08:50:31.380-0500

Change 14478 merged by Joshua Colp:
res_pjsip_logger.c: correct the return value checks when writing to pcap files

[https://gerrit.asterisk.org/c/asterisk/+/14478|https://gerrit.asterisk.org/c/asterisk/+/14478]

By: Friendly Automation (friendly-automation) 2020-06-01 08:50:54.281-0500

Change 14476 merged by Joshua Colp:
res_pjsip_logger.c: correct the return value checks when writing to pcap files

[https://gerrit.asterisk.org/c/asterisk/+/14476|https://gerrit.asterisk.org/c/asterisk/+/14476]

By: Friendly Automation (friendly-automation) 2020-06-01 08:53:06.920-0500

Change 14474 merged by Joshua Colp:
res_pjsip_logger.c: correct the return value checks when writing to pcap files

[https://gerrit.asterisk.org/c/asterisk/+/14474|https://gerrit.asterisk.org/c/asterisk/+/14474]

By: Friendly Automation (friendly-automation) 2020-06-01 08:54:09.340-0500

Change 14449 merged by Joshua Colp:
res_pjsip_logger.c: correct the return value checks when writing to pcap files

[https://gerrit.asterisk.org/c/asterisk/+/14449|https://gerrit.asterisk.org/c/asterisk/+/14449]

By: Friendly Automation (friendly-automation) 2020-06-01 08:54:27.337-0500

Change 14477 merged by Joshua Colp:
res_pjsip_logger.c: correct the return value checks when writing to pcap files

[https://gerrit.asterisk.org/c/asterisk/+/14477|https://gerrit.asterisk.org/c/asterisk/+/14477]

By: Friendly Automation (friendly-automation) 2020-06-01 08:56:07.346-0500

Change 14475 merged by Joshua Colp:
res_pjsip_logger.c: correct the return value checks when writing to pcap files

[https://gerrit.asterisk.org/c/asterisk/+/14475|https://gerrit.asterisk.org/c/asterisk/+/14475]