[Home]

Summary:ASTERISK-28809: [patch] res_rtp_asterisk: Avoid absolute value on unsigned subtraction.
Reporter:Alexander Traud (traud)Labels:patch
Date Opened:2020-04-06 07:59:10Date Closed:2020-04-08 09:32:36
Priority:MajorRegression?
Status:Closed/CompleteComponents:Resources/res_rtp_asterisk
Versions:16.9.0 17.3.0 Frequency of
Occurrence
Related
Issues:
Environment:clangAttachments:( 0) clang-6.patch
Description:Two years ago, I made a [similar mistake|https://issues.asterisk.org/jira/browse/ASTERISK-27549]. However, this code here was [added|https://github.com/asterisk/asterisk/commit/5bacde37a28c0aac2fb7d6fbbb799331c58f55e7] more than 23 months ago. More than 17 months ago, Asterisk 16 LTS was released. More than 3 months ago, Certified-Asterisk 16 was released. And nobody used the compiler Clang since then? I have an excuse for myself, because I am still with Asterisk 13 LTS. What about other users? In that time, the code was [touched|https://github.com/asterisk/asterisk/commit/87fda066eac730df655bfbf2527d6cd449cd832d] by two core team developers and passed two code reviews. What is wrong with Asterisk?
{code}res_rtp_asterisk.c:7423:14: warning: taking the absolute value of unsigned type 'unsigned int' has no effect [-Wabsolute-value]
       } else if ((abs(seqno - rtp->expectedrxseqno) > 100) ||
                   ^
res_rtp_asterisk.c:7423:14: note: remove the call to 'abs' since unsigned values cannot be negative
       } else if ((abs(seqno - rtp->expectedrxseqno) > 100) ||
                   ^~~{code}
In this case, the actual problem is that the usual compiler GCC is not asked to warn about [-Wconversion|https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wconversion] or at least [-Wsign-conversion|https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wsign-conversion]. When I enable the latter, I get thousands of warnings. Go figure!

The attached patch simply silences that warning, because I do not understand what that code actually does. If it wants to detect a distance between two sequence numbers, then the code might be wrong, because sequence numbers wrap at 0xffff; comparisons 100 packets around zero might be wrong.
Comments:By: Asterisk Team (asteriskteam) 2020-04-06 07:59:10.891-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: Friendly Automation (friendly-automation) 2020-04-08 09:32:41.914-0500

Change 14120 merged by Friendly Automation:
res_rtp_asterisk: Avoid absolute value on unsigned subtraction.

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

By: Friendly Automation (friendly-automation) 2020-04-08 09:39:21.918-0500

Change 14119 merged by Friendly Automation:
res_rtp_asterisk: Avoid absolute value on unsigned subtraction.

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

By: Friendly Automation (friendly-automation) 2020-04-08 10:03:04.747-0500

Change 14088 merged by Friendly Automation:
res_rtp_asterisk: Avoid absolute value on unsigned subtraction.

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